-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidth.c
139 lines (125 loc) · 3.22 KB
/
width.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
>HEADER
Copyright (c) 2004 Haixu Tang [email protected]
This file is part of the RepGraph package.
RepGraph is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RepGraph is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RepGraph. If not, see <http://www.gnu.org/licenses/>.
<HEADER
**/
#include <stdinc.h>
#include <extvab.h>
#include <extfunc.h>
int countwidth(NODES *node);
int countthickness(NODES *node);
void countallnode(LIST **list, int *len_seq, int num_seq);
char check_width(NODES *node1, NODES *node2);
int countwidth(NODES *node)
{
int i, j, k, l, n, width;
int read, readold;
int num_read, *readall, *widthall;
POSITION *position;
sort_nodepos(node);
readall = (int *) ckalloc(node -> npos * sizeof(int));
widthall = (int *) ckalloc(node -> npos * sizeof(int));
position = node -> position;
num_read = 0;
k = 1;
readold = -1;
while(position) {
read = position -> readindex;
if(read != readold) {
readall[num_read] = read;
widthall[num_read] = k;
num_read ++;
if(position -> position >= 0) {
k = 1;
} else {
k = 0;
}
readold = read;
} else if(position -> position >= 0) {
k ++;
}
position = position -> next;
}
width = 0;
for(i = 0; i < num_read; i ++) {
if(widthall[i] > width) {
width = widthall[i];
}
}
free((void *) readall);
free((void *) widthall);
return(width);
}
int countthickness(NODES *node)
{
int i, j, k, l, n, thickness;
int read, readold;
int mini, maxi;
POSITION *position, *pos1;
sort_nodepos(node);
position = node -> position;
mini = MAX_TMP_LEG;
while(position) {
read = position -> readindex;
pos1 = position -> next;
while(pos1 && pos1 -> readindex == read) {
if(mini > abs(position -> position - pos1 -> position) + 1) {
mini = abs(position -> position - pos1 -> position) + 1;
}
pos1 = pos1 -> next;
}
position = position -> next;
}
if(mini > MIN_WHIRL_SIZE) {
thickness = 1;
} else {
thickness = mini;
}
return(thickness);
}
char check_width(NODES *node1, NODES *node2)
{
int i, j, k, l, n, thickness;
int read1, read2;
int mini, maxi;
POSITION *position, *pos1, *pos2;
pos1 = node1 -> position;
while(pos1) {
read1 = pos1 -> readindex;
pos2 = node2 -> position;
while(pos2) {
read2 = pos2 -> readindex;
if(read1 == read2 && abs(pos1 -> position - pos2 -> position) < MIN_WHIRL_SIZE) {
return(1);
}
pos2 = pos2 -> next;
}
pos1 = pos1 -> next;
}
return(0);
}
void countallnode(LIST **list, int *len_seq, int num_seq)
{
int i, j, k, l, n;
for(i = 0; i < num_seq; i ++) {
for(j = 0; j < len_seq[i]; j ++) {
if(list[i][j].node && list[i][j].node -> visit == 0) {
list[i][j].node -> visit = 1;
n = countwidth(list[i][j].node);
list[i][j].node -> num_path = n;
}
}
}
cleannode(list, len_seq, num_seq);
}