#include "machine.h"Include dependency graph for paths.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| void | NodesToPath (int *nodes, int **p, int *psize, int *la, int *lp, int *ls) |
| void C2F() | prevn2p (int *i, int *j, int *m, int *n, int *la, int *lp, int *ls, int *direct, int *pln, int **p, int *psize) |
| void C2F() | ns2p (int *nodes, int *nsize, int **p, int *psize, int *la, int *lp, int *ls, int *n) |
| void C2F() | p2ns (int *p, int *psize, int **nodes, int *nsize, int *la, int *lp, int *ls, int *direct, int *m, int *n) |
| void C2F() | edge2st (int *n, int *alpha, int **tree, int *treesize) |
| void C2F() | prevn2st (int *n, int *nodes, int **tree, int *treesize, int *la, int *lp, int *ls) |
edge2st_ computes a spanning tree (root = node 1) from an array alpha of connecting edge numbers
Definition at line 189 of file paths.c.
References cerro(), MALLOC, and NULL.
00190 { 00191 int i; 00192 *treesize = *n - 1; 00193 if ((*tree = (int *)MALLOC(*treesize * sizeof(int))) == NULL) { 00194 cerro("Running out of memory"); 00195 return; 00196 } 00197 for (i = 1; i <= *n - 1; i++) { 00198 if (alpha[i] < 0) { 00199 *treesize=0; 00200 return; 00201 } 00202 (*tree)[i-1] = alpha[i]; 00203 } 00204 }
Here is the call graph for this function:

NodesToPath converts a vector with node numbers into a path: NODES = [Nn,...,N2,N1] => PATH = [A1,A2,...,An-1] with Ai = (Ni,Ni+1) n = *psize + 1
| nodes | ||
| p | ||
| psize | ||
| la | ||
| lp | ||
| ls |
Definition at line 13 of file paths.c.
References a, i, j, n1, and n2.
Referenced by prevn2p().
00014 { 00015 int a,i,j,n1,n2; 00016 for (i = 1; i <= *psize; i++) { 00017 n1 = nodes[*psize-i+1]; n2 = nodes[*psize-i]; 00018 a = 0; 00019 for (j = lp[n1-1]; j <= lp[n1]-1; j++) { 00020 if (n2 == ls[j-1]) { 00021 a = la[j-1]; 00022 break; 00023 } 00024 } 00025 if (a == 0) { 00026 *psize = 0; 00027 return; 00028 } 00029 (*p)[i-1] = a; 00030 } 00031 }
Here is the caller graph for this function:

| void C2F() ns2p | ( | int * | nodes, | |
| int * | nsize, | |||
| int ** | p, | |||
| int * | psize, | |||
| int * | la, | |||
| int * | lp, | |||
| int * | ls, | |||
| int * | n | |||
| ) |
ns2p_ converts a node set into a path: NODES = [N1,N2,...,Nn] => PATH = [A1,A2,...,An-1] with Ai = (Ni,Ni+1) *psize = *nsize - 1
Definition at line 75 of file paths.c.
References a, cerro(), MALLOC, n1, n2, and NULL.
00076 { 00077 int a,i,j,n1,n2; 00078 *psize = *nsize - 1; 00079 if ((*p = (int *)MALLOC(*psize * sizeof(int))) == NULL) { 00080 cerro("Running out of memory"); 00081 return; 00082 } 00083 for (i = 1; i <= *psize; i++) { 00084 n1 = nodes[i-1]; 00085 if ((i == 1) && (n1 < 0 || n1 > *n)) { 00086 sprintf(str,"Bad internal node number %d",n1); 00087 cerro(str); 00088 return; 00089 } 00090 n2 = nodes[i]; 00091 if (n2 < 0 || n2 > *n) { 00092 sprintf(str,"Bad internal node number %d",n2); 00093 cerro(str); 00094 return; 00095 } 00096 a = 0; 00097 for (j = lp[n1-1]; j <= lp[n1]-1; j++) { 00098 if (n2 == ls[j-1]) { 00099 a = la[j-1]; 00100 break; 00101 } 00102 } 00103 if (a == 0) { 00104 *psize = 0; 00105 return; 00106 } 00107 (*p)[i-1] = a; 00108 } 00109 }
Here is the call graph for this function:

| void C2F() p2ns | ( | int * | p, | |
| int * | psize, | |||
| int ** | nodes, | |||
| int * | nsize, | |||
| int * | la, | |||
| int * | lp, | |||
| int * | ls, | |||
| int * | direct, | |||
| int * | m, | |||
| int * | n | |||
| ) |
p2ns_ converts a path into a node set: PATH = [A1,A2,...,An] => NODES = [N1,N2,...,Nn+1] => with Ai = (Ni,Ni+1) with *nsize = *psize + 1
Definition at line 111 of file paths.c.
References a, cerro(), ma, MALLOC, n1, n2, and NULL.
00112 { 00113 int ma,a,i,j,k,n1,n2; 00114 *nsize = *psize + 1; 00115 if ((*nodes = (int *)MALLOC(*nsize * sizeof(int))) == NULL) { 00116 cerro("Running out of memory"); 00117 return; 00118 } 00119 if (*direct == 1) ma = *m; else ma = *m / 2; 00120 for (i = 1; i <= *psize; i++) { 00121 a = p[i-1]; 00122 if (a < 0 || a > ma) { 00123 sprintf(str,"Bad internal arc number %d",a); 00124 cerro(str); 00125 return; 00126 } 00127 /* find nodes n1 and n2 of arc a */ 00128 n1 = 0; n2 = 0; 00129 for (j = 1; j <= *n; j++) { 00130 for (k = lp[j-1]; k <= lp[j]-1; k++) 00131 if (la[k-1] == a) { 00132 n1 = j; n2 = ls[k-1]; 00133 break; 00134 } 00135 if (n1 != 0) break; 00136 } 00137 if (n1 == 0) { 00138 *nsize = 0; 00139 return; 00140 } 00141 /* directed graph */ 00142 if (*direct == 1) { 00143 if (i == 1) (*nodes)[i-1] = n1; 00144 if (i!= 1 && (*nodes)[i-1] != n1) { 00145 *nsize = 0; 00146 return; 00147 } 00148 (*nodes)[i] = n2; 00149 } 00150 /* undirected graph */ 00151 else { 00152 if (i == 1) { 00153 (*nodes)[0] = n1; (*nodes)[1] = n2; 00154 } 00155 else if (i == 2) { 00156 if (n1 == (*nodes)[0]) { 00157 (*nodes)[0] = (*nodes)[1]; 00158 (*nodes)[1] = n1; 00159 (*nodes)[2] = n2; 00160 } 00161 else if (n1 == (*nodes)[1]) { 00162 (*nodes)[2] = n2; 00163 } 00164 else if (n2 == (*nodes)[0]) { 00165 (*nodes)[0] = (*nodes)[1]; 00166 (*nodes)[1] = n2; 00167 (*nodes)[2] = n1; 00168 } 00169 else if (n2 == (*nodes)[1]) { 00170 (*nodes)[2] = n1; 00171 } 00172 else { 00173 *nsize = 0; 00174 return; 00175 } 00176 } 00177 else { 00178 if (n1 == (*nodes)[i-1]) (*nodes)[i] = n2; 00179 else if (n2 == (*nodes)[i-1]) (*nodes)[i] = n1; 00180 else { 00181 *nsize = 0; 00182 return; 00183 } 00184 } 00185 } 00186 } 00187 }
Here is the call graph for this function:

| void C2F() prevn2p | ( | int * | i, | |
| int * | j, | |||
| int * | m, | |||
| int * | n, | |||
| int * | la, | |||
| int * | lp, | |||
| int * | ls, | |||
| int * | direct, | |||
| int * | pln, | |||
| int ** | p, | |||
| int * | psize | |||
| ) |
prevn2p_ computes a path from node i to node j from a vector describing the previous nodes in path: node i belongs to path if pln[i] > 0 pln[i] is then the previous node in the sequence
Definition at line 33 of file paths.c.
References cerro(), FREE, MALLOC, NodesToPath(), and NULL.
00034 { 00035 int *nodes; 00036 int k,nn; 00037 if (*i < 0 || *i > *n) { 00038 sprintf(str,"Bad internal node number %d",*i); 00039 cerro(str); 00040 return; 00041 } 00042 if (*j < 0 || *j > *n) { 00043 sprintf(str,"Bad internal node number %d",*j); 00044 cerro(str); 00045 return; 00046 } 00047 if ((nodes = (int *)MALLOC((*m + 1) * sizeof(int))) == NULL) { 00048 cerro("Running out of memory"); 00049 return; 00050 } 00051 nn = 0; 00052 nodes[nn++] = *j; 00053 k = 0; 00054 /* the first time, the test must be always verified for dealing with 00055 circuits */ 00056 while (k != *i) { 00057 if (nn == 1) k = *j; 00058 k = pln[k-1]; 00059 nodes[nn++] = k; 00060 if (k <= 0 || k > *n || nn > *n + 1) { 00061 /* there is no path */ 00062 *psize = 0; 00063 return; 00064 } 00065 } 00066 *psize = nn - 1; 00067 if ((*p = (int *)MALLOC(*psize * sizeof(int))) == NULL) { 00068 cerro("Running out of memory"); 00069 return; 00070 } 00071 NodesToPath(nodes,p,psize,la,lp,ls); 00072 FREE(nodes); 00073 }
Here is the call graph for this function:

| void C2F() prevn2st | ( | int * | n, | |
| int * | nodes, | |||
| int ** | tree, | |||
| int * | treesize, | |||
| int * | la, | |||
| int * | lp, | |||
| int * | ls | |||
| ) |
prevn2st_ computes a spanning tree (root = node i0) from a vector nodes describing the previous nodes in tree
Definition at line 206 of file paths.c.
References cerro(), MALLOC, and NULL.
00207 { 00208 int i,in,j,nt,indic; 00209 *treesize = *n - 1; 00210 if ((*tree = (int *)MALLOC(*treesize * sizeof(int))) == NULL) { 00211 cerro("Running out of memory"); 00212 return; 00213 } 00214 nt = 0; 00215 indic=0; 00216 for (i = 1; i <= *n; i++) { 00217 in = nodes[i-1]; 00218 if (in == 0) continue; 00219 /* arc (in,i) belongs to tree */ 00220 indic=1; 00221 for (j = lp[in-1]; j <= lp[in]-1; j++) { 00222 if (ls[j-1] == i) { 00223 (*tree)[nt++] = la[j-1]; 00224 break; 00225 } 00226 } 00227 } 00228 if (indic == 0) *treesize=0; 00229 }
Here is the call graph for this function:

1.5.1