[BACK]Return to tsort.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tsort

Diff for /src/usr.bin/tsort/tsort.c between version 1.9 and 1.10

version 1.9, 2001/05/01 20:36:57 version 1.10, 2001/07/14 14:18:50
Line 148 
Line 148 
 static struct node *find_smallest_node __P((struct array *));  static struct node *find_smallest_node __P((struct array *));
 static struct node *find_good_cycle_break __P((struct array *));  static struct node *find_good_cycle_break __P((struct array *));
 static void print_cycle __P((struct array *));  static void print_cycle __P((struct array *));
 static int find_cycle_with __P((struct node *, struct array *));  static struct node *find_cycle_from __P((struct node *, struct array *));
 static struct node *find_predecessor __P((struct array *, struct node *));  static struct node *find_predecessor __P((struct array *, struct node *));
 static unsigned int traverse_node __P((struct node *, unsigned int, struct array *));  static unsigned int traverse_node __P((struct node *, unsigned int, struct array *));
 static struct node *find_longest_cycle __P((struct array *, struct array *));  static struct node *find_longest_cycle __P((struct array *, struct array *));
Line 649 
Line 649 
  *** Graph algorithms.   *** Graph algorithms.
  ***/   ***/
   
 /* Explore the nodes reachable from i to find a cycle containing it, store  /* Explore the nodes reachable from i to find a cycle, store it in c.
  * it in c.  This may fail.  */   * This may fail.  */
 static int  static struct node *
 find_cycle_with(i, c)  find_cycle_from(i, c)
         struct node     *i;          struct node     *i;
         struct array    *c;          struct array    *c;
 {  {
Line 676 
Line 676 
                         struct node *go = n->traverse->node;                          struct node *go = n->traverse->node;
   
                         if (go->mark) {                          if (go->mark) {
                                 if (go == i) {                                  c->entries = 0;
                                         c->entries = 0;                                  for (; n != NULL && n != go; n = n->from) {
                                         for (; n != NULL; n = n->from)                                          c->t[c->entries++] = n;
                                                 c->t[c->entries++] = n;                                          n->mark = 0;
                                         return 1;  
                                 }                                  }
                                   for (; n != NULL; n = n->from)
                                           n->mark = 0;
                                   c->t[c->entries++] = go;
                                   return go;
                         } else {                          } else {
                             go->from = n;                              go->from = n;
                             n = go;                              n = go;
Line 690 
Line 693 
                         n->mark = 0;                          n->mark = 0;
                         n = n->from;                          n = n->from;
                         if (n == NULL)                          if (n == NULL)
                                 return 0;                                  return NULL;
                 }                  }
         }          }
 }  }
Line 991 
Line 994 
                             if (long_flag) {                              if (long_flag) {
                                     n = find_longest_cycle(&remaining, &aux);                                      n = find_longest_cycle(&remaining, &aux);
                             } else {                              } else {
                                       struct node *b;
   
                                     if (hints_flag)                                      if (hints_flag)
                                             n = find_smallest_node(&remaining);                                              n = find_smallest_node(&remaining);
                                     else                                      else
                                             n = find_good_cycle_break(&remaining);                                              n = find_good_cycle_break(&remaining);
                                     if (!quiet_flag) {                                      while ((b = find_cycle_from(n, &aux)) == NULL)
                                             while (!find_cycle_with(n, &aux))                                              n = find_predecessor(&remaining, n);
                                                     n = find_predecessor(&remaining, n);                                      n = b;
                                     }  
                             }                              }
   
                             if (!quiet_flag) {                              if (!quiet_flag) {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10