MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / LongestPathTree

Function LongestPathTree

src/algorithms/longest_path.c:83–98  ·  view source on GitHub ↗

Finds the longest path in an acyclic graph.

Source from the content-addressed store, hash-verified

81
82// Finds the longest path in an acyclic graph.
83QGNode *LongestPathTree(const QueryGraph *g, int *level) {
84 int l = BFS_LOWEST_LEVEL;
85 QGNode **leafs = BFS(g->nodes[0], &l);
86 QGNode *leaf = leafs[0];
87 array_free(leafs);
88
89 l = BFS_LOWEST_LEVEL;
90 leafs = BFS(leaf, &l);
91
92 ASSERT(array_len(leafs) > 0 && l >= 0);
93 QGNode *n = leafs[0];
94 array_free(leafs);
95
96 *level = l;
97 return n;
98}
99

Callers 1

Calls 3

BFSFunction · 0.85
array_freeFunction · 0.85
array_lenFunction · 0.85

Tested by

no test coverage detected