Finds the longest path in an acyclic graph.
| 81 | |
| 82 | // Finds the longest path in an acyclic graph. |
| 83 | QGNode *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 |
no test coverage detected