home *** CD-ROM | disk | FTP | other *** search
- /* > H.Graph - Graph data type header file */
-
- #ifndef __graph_h
-
- #define __graph_h
-
- struct arc
- {
- struct node *start; /* Starting node for the arc */
- struct node *end; /* Ending node for the arc */
- char weight[1]; /* Weight associated with this arc */
- };
-
- struct node
- {
- int num_succ; /* Number of successors */
- int num_pred; /* Number of predecessors */
- struct arclist *preds; /* Predecessor arc list */
- struct arclist *succs; /* Successor arc list */
- char value[1]; /* Value associated with this node */
- };
-
- struct arclist
- {
- struct arclist *next; /* Next arc in the list */
- struct arc *arc; /* Pointer to this arc value */
- }
-
- struct nodelist
- {
- struct nodelist *next; /* Next node in the list */
- struct node *node; /* Pointer to this node value */
- }
-
- struct graph
- {
- int val_len; /* Number of bytes in a node value */
- int weight_len; /* Number of bytes in an arc weight */
- struct nodelist *nodes; /* Nodes of the graph */
- };
-
- typedef struct arc *arc;
- typedef struct node *node;
- typedef struct graph *graph;
-
- /* General component routines */
-
- graph graph_new (int val_len, int weight_len);
- void graph_free (graph g);
- void graph_clear (graph g);
- int graph_copy (graph g1, graph g2);
- int graph_equal (graph g1, graph g2);
- int graph_empty (graph g);
- int graph_size (graph g);
-
- /* Iterator */
-
- #define STATUS_CONTINUE 0 /* Continue processing */
- #define STATUS_STOP 1 /* Stop processing */
- #define STATUS_ERROR (-1) /* Error - terminate */
-
- int graph_iterate (graph g, int (*process)(void *));
-
- /* Graph-specific routines */
-
- #endif
-