X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fagar%2Ftest%2Fnegacycle.c;fp=ccan%2Fagar%2Ftest%2Fnegacycle.c;h=7d3daa963bcb6a16c9a0fc6af2cf983fa6ead085;hb=318edb2466a24a2eadcfd05fa83ae29c0e8aae03;hp=0000000000000000000000000000000000000000;hpb=eedf1079f38efb2b8dc4fd3f516cce8ac1272c06;p=ccan diff --git a/ccan/agar/test/negacycle.c b/ccan/agar/test/negacycle.c new file mode 100644 index 00000000..7d3daa96 --- /dev/null +++ b/ccan/agar/test/negacycle.c @@ -0,0 +1,42 @@ +#include "config.h" + +#include + +#include +#include + +#include + +#include "simple-graphr.h" + +static const void *negacycle_first_edge_r(const struct agar_graph *gr, + const void *nr) +{ + return int2ptr(1); +} + +static const void *negacycle_next_edge_r(const struct agar_graph *gr, + const void *nr, const void *e) +{ + assert(ptr2int(e) == 1); + return NULL; +} + +static int negacycle_edge_info_r(const struct agar_graph *gr, + const void *nr, const void *e, + struct agar_edge_info *eir) +{ + int ni = ptr2int(nr); + + assert(ptr2int(e) == 1); + eir->to = int2ptr((ni % 3) + 1); + if (ni == 3) + eir->icost = -3; + return 0; +} + +struct negacycle_graphr negacycle_graphr = { + AGAR_INIT_GRAPH(negacycle_first_edge_r, + negacycle_next_edge_r, + negacycle_edge_info_r), +};