Go to the documentation of this file.00001 #include "cs.h"
00002
00003 int cs_tdfs (int j, int k, int *head, const int *next, int *post, int *stack)
00004 {
00005 int i, p, top = 0 ;
00006 if (!head || !next || !post || !stack) return (-1) ;
00007 stack [0] = j ;
00008 while (top >= 0)
00009 {
00010 p = stack [top] ;
00011 i = head [p] ;
00012 if (i == -1)
00013 {
00014 top-- ;
00015 post [k++] = p ;
00016 }
00017 else
00018 {
00019 head [p] = next [i] ;
00020 stack [++top] = i ;
00021 }
00022 }
00023 return (k) ;
00024 }