MCPcopy Create free account
hub / github.com/ElementsProject/lightning / problem2

Function problem2

plugins/askrene/test/run-flow.c:62–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62static void problem2(void){
63 /* Stress the graph constraints by setting max_num_nodes to exactly the
64 * number of node that participate and put all nodes in line to achieve
65 * the largest path length possible. */
66 printf("Allocating a memory context\n");
67 tal_t *ctx = tal(NULL, tal_t);
68 assert(ctx);
69
70 printf("Allocating a graph\n");
71 struct graph *graph = graph_new(ctx, 5, MAX_ARCS, DUAL_BIT);
72 assert(graph);
73
74 s64 *capacity = tal_arrz(ctx, s64, MAX_ARCS);
75
76 graph_add_arc(graph, arc_obj(0), node_obj(0), node_obj(1));
77 capacity[0] = 1;
78 graph_add_arc(graph, arc_obj(1), node_obj(1), node_obj(2));
79 capacity[1] = 4;
80 graph_add_arc(graph, arc_obj(2), node_obj(2), node_obj(3));
81 capacity[2] = 1;
82 graph_add_arc(graph, arc_obj(3), node_obj(3), node_obj(4));
83 capacity[3] = 1;
84
85 struct node src = {.idx = 0};
86 struct node dst = {.idx = 4};
87
88 bool result = simple_feasibleflow(ctx, graph, src, dst, capacity, 1);
89 CHECK(result);
90
91 CHECK(node_balance(graph, src, capacity) == -1);
92 CHECK(node_balance(graph, dst, capacity) == 1);
93
94 for (u32 i = 1; i < 4; i++)
95 CHECK(node_balance(graph, node_obj(i), capacity) == 0);
96
97 printf("Freeing memory\n");
98 ctx = tal_free(ctx);
99}
100
101int main(int argc, char *argv[])
102{

Callers 1

mainFunction · 0.85

Calls 7

graph_newFunction · 0.85
graph_add_arcFunction · 0.85
arc_objFunction · 0.85
node_objFunction · 0.85
simple_feasibleflowFunction · 0.85
node_balanceFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected