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

Function graph_new

plugins/askrene/child/graph.c:39–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39struct 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)
41{
42 struct graph *graph;
43 graph = tal(ctx, struct graph);
44
45 graph->max_num_arcs = max_num_arcs;
46 graph->max_num_nodes = max_num_nodes;
47 graph->arc_dual_bit = arc_dual_bit;
48
49 graph->arc_tail = tal_arr(graph, struct node, graph->max_num_arcs);
50 graph->node_adjacency_first =
51 tal_arr(graph, struct arc, graph->max_num_nodes);
52 graph->node_adjacency_next =
53 tal_arr(graph, struct arc, graph->max_num_arcs);
54
55 /* initialize with invalid indexes so that we know these slots have
56 * never been used, eg. arc/node is newly created */
57 for (size_t i = 0; i < graph->max_num_arcs; i++)
58 graph->arc_tail[i] = node_obj(INVALID_INDEX);
59 for (size_t i = 0; i < graph->max_num_nodes; i++)
60 graph->node_adjacency_first[i] = arc_obj(INVALID_INDEX);
61 for (size_t i = 0; i < graph->max_num_nodes; i++)
62 graph->node_adjacency_next[i] = arc_obj(INVALID_INDEX);
63
64 return graph;
65}

Callers 9

solve_caseFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
problem1Function · 0.85
problem2Function · 0.85
mainFunction · 0.85
init_linear_networkFunction · 0.85

Calls 2

node_objFunction · 0.85
arc_objFunction · 0.85

Tested by 7

solve_caseFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
problem1Function · 0.68
problem2Function · 0.68
mainFunction · 0.68