5 #include <ccan/agar/agar.h>
6 #include <ccan/container_of/container_of.h>
7 #include <ccan/ptrint/ptrint.h>
9 #include "simple-graphr.h"
11 static const void *parallel_first_edge_r(const struct agar_graph *gr,
14 const struct parallel_graphr *pgr
15 = container_of(gr, struct parallel_graphr, gr);
17 if (ptr2int(nr) != 1) {
18 assert(ptr2int(nr) == 2);
28 static const void *parallel_next_edge_r(const struct agar_graph *gr,
29 const void *nr, const void *edge)
31 const struct parallel_graphr *pgr
32 = container_of(gr, struct parallel_graphr, gr);
33 int index = ptr2int(edge);
35 if (ptr2int(nr) != 1) {
36 assert(ptr2int(nr) == 2);
40 if (index < pgr->nlinks)
41 return int2ptr(index + 1);
46 static int parallel_edge_info_r(const struct agar_graph *gr,
47 const void *nr, const void *edge,
48 struct agar_edge_info *eir)
50 assert(ptr2int(nr) == 1);
56 void parallel_graphr_init(struct parallel_graphr *pgr, int nlinks)
60 agar_init_graph(&pgr->gr, parallel_first_edge_r, parallel_next_edge_r,
61 parallel_edge_info_r);