]> git.ozlabs.org Git - ccan/blob - ccan/aga/test/chain.c
aga: Simple test graphs
[ccan] / ccan / aga / test / chain.c
1 #include "config.h"
2
3 #include <stdlib.h>
4
5 #include <ccan/container_of/container_of.h>
6
7 #include <ccan/aga/aga.h>
8
9 #include "simple-graph.h"
10
11 static int chain_edge_info(const struct aga_graph *g,
12                            const struct aga_node *node,
13                            struct aga_node *edge,
14                            struct aga_edge_info *ei)
15 {
16         if ((edge == node + 1) || (node == edge + 1))
17                 ei->to = edge;
18
19         return 0;
20 }
21
22 void chain_graph_init(struct chain_graph *cg, int nnodes)
23 {
24         cg->fg.nnodes = nnodes;
25         simple_graph_init(&cg->fg.sg, full_first_edge, full_next_edge,
26                           chain_edge_info);
27 }