1 #ifndef _SIMPLE_GRAPHR_H
2 #define _SIMPLE_GRAPHR_H
6 #define MAX_EDGES 16 /* Max edges per node */
8 struct adjacency_listr {
17 * The simplest possible graph: one node, no edges
19 struct trivial_graphr {
22 void trivial_graphr_init(struct trivial_graphr *tgr);
23 static const struct adjacency_listr trivial_adjacencyr[] = {
36 * Two nodes (A & B), with PARALLEL_NLINKS edges all from A->B.
38 struct parallel_graphr {
42 void parallel_graphr_init(struct parallel_graphr *pgr, int nlinks);
43 static const struct adjacency_listr parallel_adjacencyr_nlinks3[] = {
51 * n nodes with an edge from every node to every other node (including
58 void full_graphr_init(struct full_graphr *fgr, int nnodes);
59 static const struct adjacency_listr full_adjacencyr_5[] = {
67 const void *full_first_edge_r(const struct agar_graph *gr, const void *nr);
68 const void *full_next_edge_r(const struct agar_graph *gr,
69 const void *nr, const void *e);
78 * nnodes nodes arranged in a linear sequence, edges from each node to
79 * the previous and next
82 struct full_graphr fgr;
84 void chain_graphr_init(struct chain_graphr *cgr, int nnodes);
85 static const struct adjacency_listr chain_adjacencyr_8[] = {
108 * nx * ny nodes arranged in an nx * ny grid. Depending on
109 * parameters, edges to the node to the right / down / left / up of
114 bool right, down, left, up;
115 struct agar_graph gr;
117 void grid_graphr_init(struct grid_graphr *ggr, int nx, int ny,
118 bool right, bool down, bool left, bool up);
119 static const struct adjacency_listr grid_adjacencyr_3x3_rightdown[] = {
131 static const struct adjacency_listr grid_adjacencyr_3x3_all[] = {
150 * This is for testing reporting of errors by the edge_info function.
151 * 5 nodes are arranged as above, with the link from D always
152 * returning an error.
154 struct error_graphr {
155 struct agar_graph gr;
157 void error_graphr_init(struct error_graphr *eg);
158 static const struct adjacency_listr error_adjacencyr[] = {
178 * This provides an example of a graph which can't be traversed (with
179 * DFS or BFS) from a single starting node. It can be traversed with
180 * two starting points, but several nodes can be reached from either,
181 * complicating the logic to avoid double-traversal.
183 struct traversal1_graphr {
184 struct agar_graph gr;
186 void traversal1_graphr_init(struct traversal1_graphr *t1gr);
187 static const struct adjacency_listr traversal1_adjacency[] = {
200 #endif /* _SIMPLE_GRAPHR_H */