TopologicalSort

com.phasmidsoftware.gryphon.traverse.TopologicalSort
See theTopologicalSort companion class

Provides functionality for topological sorting of directed graphs using the Visitor V1.2.0 typeclass engine.

Post-order DFS is used: a vertex is recorded only after all its descendants have been recorded, naturally yielding reverse topological order.

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def sort[V, E](graph: DirectedGraph[V, E]): Option[Seq[V]]

Performs a topological sort on the given directed graph.

Performs a topological sort on the given directed graph.

Uses post-order DFS (DfsOrder.Post) via Traversal.dfs so that each vertex appears in the journal only after all vertices reachable from it. The resulting list is in reverse post-order (i.e. topological order).

Returns None if the graph is cyclic.

Type parameters

E

the edge attribute type.

V

the vertex attribute type.

Value parameters

graph

the directed graph to sort.

Attributes

Returns

Some(Seq[V]) in topological order, or None if the graph is cyclic.

def traversal[V, E](graph: DirectedGraph[V, E]): Option[TopologicalSort[V]]

Computes a TopologicalSort mapping from the given directed graph, or returns None if the graph is cyclic.

Computes a TopologicalSort mapping from the given directed graph, or returns None if the graph is cyclic.

Type parameters

E

the edge attribute type.

V

the vertex attribute type.

Value parameters

graph

the directed graph to sort.

Attributes

Returns

Some(TopologicalSort[V]) with each vertex mapped to its position, or None if the graph is cyclic.