toDirectedGraph method
Converts a Model to a DirectedGraph
from the directed_graph
library.
May be useful for further analysis of the dependency graph.
Implementation
DirectedGraph<String> toDirectedGraph() {
var edgeMap = <String, Set<String>>{};
// Add nodes
for (var node in nodes.values) {
if (!edgeMap.containsKey(node.id)) {
edgeMap[node.id] = {};
}
}
// Add edges
for (var edge in edges) {
edgeMap[edge.from]!.add(edge.to);
}
return DirectedGraph<String>(edgeMap);
}