Go to the documentation of this file.00001 #include "cs.h"
00002
00003 int cs_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf,
00004 int *ancestor, int *jleaf)
00005 {
00006 int q, s, sparent, jprev ;
00007 if (!first || !maxfirst || !prevleaf || !ancestor || !jleaf) return (-1) ;
00008 *jleaf = 0 ;
00009 if (i <= j || first [j] <= maxfirst [i]) return (-1) ;
00010 maxfirst [i] = first [j] ;
00011 jprev = prevleaf [i] ;
00012 prevleaf [i] = j ;
00013 *jleaf = (jprev == -1) ? 1: 2 ;
00014 if (*jleaf == 1) return (i) ;
00015 for (q = jprev ; q != ancestor [q] ; q = ancestor [q]) ;
00016 for (s = jprev ; s != q ; s = sparent)
00017 {
00018 sparent = ancestor [s] ;
00019 ancestor [s] = q ;
00020 }
00021 return (q) ;
00022 }