findPath method
DFS path from startId to goalId. Returns the node path or [].
Implementation
List<ConceptNode> findPath(String startId, String goalId) {
final visited = <String>{};
final path = <ConceptNode>[];
bool dfs(String currentId) {
if (visited.contains(currentId)) return false;
visited.add(currentId);
final node = _nodes[currentId];
if (node == null) return false;
path.add(node);
if (currentId == goalId) return true;
for (final edge in node.edges.values) {
if (dfs(edge.targetId)) return true;
}
path.removeLast();
return false;
}
dfs(startId);
return path;
}