DirectedGraph

A directed graph implementation. This is a subclass of Graph.

DirectedGraph:connect(nodeA, nodeB)

View source

Connects two nodes.

Arguments:

  • nodeA (Graph.Node): starting node.
  • nodeB (Graph.Node): ending node.

DirectedGraph:topologicalSort()

View source

Returns nodes in this graph in topologically sorted order

Returns:

  • (table)

DirectedGraph:hasCycle()

View source

Returns whether the graph has a cycle

Returns:

  • (boolean)

DirectedGraph:transpose()

View source

Returns a transpose of this graph (eg. with the edges reversed)

Returns:

  • (DirectedGraph)

DirectedGraph:stronglyConnectedComponents()

View source

Returns strongly connected components.

Each strongly connected component is itself a table.

Returns:

  • (table[table]) a table of strongly connected components.