Go to the documentation of this file.00001 #include "cs.h"
00002
00003 int cs_ereach (const cs *A, int k, const int *parent, int *s, int *w)
00004 {
00005 int i, p, n, len, top, *Ap, *Ai ;
00006 if (!CS_CSC (A) || !parent || !s || !w) return (-1) ;
00007 top = n = A->n ; Ap = A->p ; Ai = A->i ;
00008 CS_MARK (w, k) ;
00009 for (p = Ap [k] ; p < Ap [k+1] ; p++)
00010 {
00011 i = Ai [p] ;
00012 if (i > k) continue ;
00013 for (len = 0 ; !CS_MARKED (w,i) ; i = parent [i])
00014 {
00015 s [len++] = i ;
00016 CS_MARK (w, i) ;
00017 }
00018 while (len > 0) s [--top] = s [--len] ;
00019 }
00020 for (p = top ; p < n ; p++) CS_MARK (w, s [p]) ;
00021 CS_MARK (w, k) ;
00022 return (top) ;
00023 }