home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / unixtools / util / dev / h / graph next >
Encoding:
Text File  |  1992-07-21  |  1.7 KB  |  67 lines

  1. /*      > H.Graph - Graph data type header file */
  2.  
  3. #ifndef __graph_h
  4.  
  5. #define __graph_h
  6.  
  7. struct arc
  8. {
  9.         struct node *start;     /* Starting node for the arc */
  10.         struct node *end;       /* Ending node for the arc */
  11.         char weight[1];         /* Weight associated with this arc */
  12. };
  13.  
  14. struct node
  15. {
  16.         int num_succ;           /* Number of successors */
  17.         int num_pred;           /* Number of predecessors */
  18.         struct arclist *preds;  /* Predecessor arc list */
  19.         struct arclist *succs;  /* Successor arc list */
  20.         char value[1];          /* Value associated with this node */
  21. };
  22.  
  23. struct arclist
  24. {
  25.         struct arclist *next;   /* Next arc in the list */
  26.         struct arc *arc;        /* Pointer to this arc value */
  27. }
  28.  
  29. struct nodelist
  30. {
  31.         struct nodelist *next;  /* Next node in the list */
  32.         struct node *node;      /* Pointer to this node value */
  33. }
  34.  
  35. struct graph
  36. {
  37.         int val_len;            /* Number of bytes in a node value */
  38.         int weight_len;         /* Number of bytes in an arc weight */
  39.         struct nodelist *nodes; /* Nodes of the graph */
  40. };
  41.  
  42. typedef struct arc   *arc;
  43. typedef struct node  *node;
  44. typedef struct graph *graph;
  45.  
  46. /* General component routines */
  47.  
  48. graph graph_new (int val_len, int weight_len);
  49. void graph_free (graph g);
  50. void graph_clear (graph g);
  51. int graph_copy (graph g1, graph g2);
  52. int graph_equal (graph g1, graph g2);
  53. int graph_empty (graph g);
  54. int graph_size (graph g);
  55.  
  56. /* Iterator */
  57.  
  58. #define STATUS_CONTINUE 0       /* Continue processing */
  59. #define STATUS_STOP     1       /* Stop processing */
  60. #define STATUS_ERROR    (-1)    /* Error - terminate */
  61.  
  62. int graph_iterate (graph g, int (*process)(void *));
  63.  
  64. /* Graph-specific routines */
  65.  
  66. #endif
  67.