Go to the documentation of this file.00001 #include "cs.h"
00002
00003 int cs_dfs (int j, cs *G, int top, int *xi, int *pstack, const int *pinv)
00004 {
00005 int i, p, p2, done, jnew, head = 0, *Gp, *Gi ;
00006 if (!CS_CSC (G) || !xi || !pstack) return (-1) ;
00007 Gp = G->p ; Gi = G->i ;
00008 xi [0] = j ;
00009 while (head >= 0)
00010 {
00011 j = xi [head] ;
00012 jnew = pinv ? (pinv [j]) : j ;
00013 if (!CS_MARKED (Gp, j))
00014 {
00015 CS_MARK (Gp, j) ;
00016 pstack [head] = (jnew < 0) ? 0 : CS_UNFLIP (Gp [jnew]) ;
00017 }
00018 done = 1 ;
00019 p2 = (jnew < 0) ? 0 : CS_UNFLIP (Gp [jnew+1]) ;
00020 for (p = pstack [head] ; p < p2 ; p++)
00021 {
00022 i = Gi [p] ;
00023 if (CS_MARKED (Gp, i)) continue ;
00024 pstack [head] = p ;
00025 xi [++head] = i ;
00026 done = 0 ;
00027 break ;
00028 }
00029 if (done)
00030 {
00031 head-- ;
00032 xi [--top] = j ;
00033 }
00034 }
00035 return (top) ;
00036 }