X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Faga%2Ftest%2Fchain.c;fp=ccan%2Faga%2Ftest%2Fchain.c;h=fbb0f90ddf56227f4106c555b40cd3cd5676d0f9;hb=2192bdd98afbb1ddb489c863edd191877051de8b;hp=0000000000000000000000000000000000000000;hpb=3b7409ea08a7d1643bc7de31ece63e20b89f319b;p=ccan diff --git a/ccan/aga/test/chain.c b/ccan/aga/test/chain.c new file mode 100644 index 00000000..fbb0f90d --- /dev/null +++ b/ccan/aga/test/chain.c @@ -0,0 +1,27 @@ +#include "config.h" + +#include + +#include + +#include + +#include "simple-graph.h" + +static int chain_edge_info(const struct aga_graph *g, + const struct aga_node *node, + struct aga_node *edge, + struct aga_edge_info *ei) +{ + if ((edge == node + 1) || (node == edge + 1)) + ei->to = edge; + + return 0; +} + +void chain_graph_init(struct chain_graph *cg, int nnodes) +{ + cg->fg.nnodes = nnodes; + simple_graph_init(&cg->fg.sg, full_first_edge, full_next_edge, + chain_edge_info); +}