X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fagar%2Ftest%2Ffull.c;fp=ccan%2Fagar%2Ftest%2Ffull.c;h=dab6c5029404c3c85a5ff54baac4f10308e94387;hb=c2966d1879c825cfaf0e7d6848a5da052ee4a038;hp=0000000000000000000000000000000000000000;hpb=06162212353c882249d7e207756ea81ea645fc30;p=ccan diff --git a/ccan/agar/test/full.c b/ccan/agar/test/full.c new file mode 100644 index 00000000..dab6c502 --- /dev/null +++ b/ccan/agar/test/full.c @@ -0,0 +1,45 @@ +#include "config.h" + +#include +#include + +#include +#include + +#include + +#include "simple-graphr.h" + +const void *full_first_edge_r(const struct agar_graph *gr, + const void *nr) +{ + return int2ptr(1); +} + +const void *full_next_edge_r(const struct agar_graph *gr, + const void *nr, const void *e) +{ + struct full_graphr *fgr = container_of(gr, struct full_graphr, gr); + int ni = ptr2int(e); + + ni += 1; + if (ni <= fgr->nnodes) + return int2ptr(ni); + else + return NULL; +} + +static int full_edge_info_r(const struct agar_graph *gr, + const void *nr, const void *edge, + struct agar_edge_info *eir) +{ + eir->to = edge; + return 0; +} + +void full_graphr_init(struct full_graphr *fgr, int nnodes) +{ + fgr->nnodes = nnodes; + agar_init_graph(&fgr->gr, full_first_edge_r, full_next_edge_r, + full_edge_info_r); +}