DirectedGraph
A directed graph implementation.
This is a subclass of Graph
.
DirectedGraph:connect(nodeA, nodeB)
Connects two nodes.
Arguments:
nodeA
(Graph.Node
): starting node.nodeB
(Graph.Node
): ending node.
DirectedGraph:topologicalSort()
Returns nodes in this graph in topologically sorted order
Returns:
- (
table
)
DirectedGraph:hasCycle()
Returns whether the graph has a cycle
Returns:
- (
boolean
)
DirectedGraph:transpose()
Returns a transpose of this graph (eg. with the edges reversed)
Returns:
- (
DirectedGraph
)
DirectedGraph:stronglyConnectedComponents()
Returns strongly connected components.
Each strongly connected component is itself a table.
Returns:
- (
table[table]
) a table of strongly connected components.