5 #include <ccan/aga/aga.h>
6 #include <ccan/container_of/container_of.h>
7 #include <ccan/ptrint/ptrint.h>
9 #include "simple-graph.h"
11 static ptrint_t *parallel_first_edge(const struct aga_graph *g,
12 const struct aga_node *n)
14 struct parallel_graph *pg = container_of(g, struct parallel_graph, sg.g);
16 if (n != &pg->sg.nodes[1]) {
17 assert(n == &pg->sg.nodes[2]);
27 static ptrint_t *parallel_next_edge(const struct aga_graph *g,
28 const struct aga_node *n,
31 struct parallel_graph *pg = container_of(g, struct parallel_graph, sg.g);
32 int index = ptr2int(edge);
34 if (n != &pg->sg.nodes[1]) {
35 assert(n == &pg->sg.nodes[2]);
39 if (index < pg->nlinks)
40 return int2ptr(index + 1);
45 static int parallel_edge_info(const struct aga_graph *g, const struct aga_node *n,
46 ptrint_t *edge, struct aga_edge_info *ei)
48 struct parallel_graph *pg = container_of(g, struct parallel_graph, sg.g);
50 assert(n == &pg->sg.nodes[1]);
52 ei->to = &pg->sg.nodes[2];
56 void parallel_graph_init(struct parallel_graph *pg, int nlinks)
60 simple_graph_init(&pg->sg, parallel_first_edge, parallel_next_edge,