X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Faga%2Ftest%2Ffull.c;fp=ccan%2Faga%2Ftest%2Ffull.c;h=f04486afceddee586a171f29b817773aa371821d;hb=2192bdd98afbb1ddb489c863edd191877051de8b;hp=0000000000000000000000000000000000000000;hpb=3b7409ea08a7d1643bc7de31ece63e20b89f319b;p=ccan diff --git a/ccan/aga/test/full.c b/ccan/aga/test/full.c new file mode 100644 index 00000000..f04486af --- /dev/null +++ b/ccan/aga/test/full.c @@ -0,0 +1,49 @@ +#include "config.h" + +#include +#include + +#include + +#include + +#include "simple-graph.h" + +struct aga_node *full_first_edge(const struct aga_graph *g, + const struct aga_node *node) +{ + struct full_graph *fg = container_of(g, struct full_graph, sg.g); + + return &fg->sg.nodes[1]; +} + +struct aga_node *full_next_edge(const struct aga_graph *g, + const struct aga_node *node, + struct aga_node *edge) +{ + struct full_graph *fg = container_of(g, struct full_graph, sg.g); + int index = (edge - fg->sg.nodes); + + if (index < fg->nnodes) + return &fg->sg.nodes[index + 1]; + else + return NULL; +} + +static int full_edge_info(const struct aga_graph *g, + const struct aga_node *node, + struct aga_node *edge, + struct aga_edge_info *ei) +{ + ei->to = edge; + return 0; +} + +void full_graph_init(struct full_graph *fg, int nnodes) +{ + assert(nnodes < MAX_NODES); + + fg->nnodes = nnodes; + simple_graph_init(&fg->sg, full_first_edge, full_next_edge, + full_edge_info); +}