5 int i, k, p, m, n, inext, *Ap, *Ai, *w, *parent, *ancestor, *prev ;
6 if (!
CS_CSC (A))
return (NULL) ;
7 m = A->
m ; n = A->
n ; Ap = A->
p ; Ai = A->
i ;
8 parent = (
int*)
cs_malloc (n,
sizeof (
int)) ;
9 w = (
int*)
cs_malloc (n + (ata ? m : 0),
sizeof (int)) ;
10 if (!w || !parent)
return (
cs_idone (parent, NULL, w, 0)) ;
11 ancestor = w ; prev = w + n ;
12 if (ata)
for (i = 0 ; i < m ; i++) prev [i] = -1 ;
13 for (k = 0 ; k < n ; k++)
17 for (p = Ap [k] ; p < Ap [k+1] ; p++)
19 i = ata ? (prev [Ai [p]]) : (Ai [p]) ;
20 for ( ; i != -1 && i < k ; i = inext)
22 inext = ancestor [i] ;
24 if (inext == -1) parent [i] = k ;
26 if (ata) prev [Ai [p]] = k ;
29 return (
cs_idone (parent, NULL, w, 1)) ;
int * cs_etree(const cs *A, int ata)
int * cs_idone(int *p, cs *C, void *w, int ok)
void * cs_malloc(int n, size_t size)