| 20 | } |
| 21 | |
| 22 | bool graph_add_arc(struct graph *graph, const struct arc arc, |
| 23 | const struct node from, const struct node to) |
| 24 | { |
| 25 | assert(from.idx < graph->max_num_nodes); |
| 26 | assert(to.idx < graph->max_num_nodes); |
| 27 | |
| 28 | const struct arc dual = arc_dual(graph, arc); |
| 29 | |
| 30 | if (arc.idx >= graph->max_num_arcs || dual.idx >= graph->max_num_arcs) |
| 31 | return false; |
| 32 | |
| 33 | graph_push_outbound_arc(graph, arc, from); |
| 34 | graph_push_outbound_arc(graph, dual, to); |
| 35 | |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | struct graph *graph_new(const tal_t *ctx, const size_t max_num_nodes, |
| 40 | const size_t max_num_arcs, const size_t arc_dual_bit) |