class Tangle::Directed::Acyclic::Graph

A directed acyclic graph

Public Instance Methods

topological_ordering(*vertices) click to toggle source

Return a topological ordering of a set of vertices, or all vertices in the graph.

# File lib/tangle/directed/acyclic/graph.rb, line 13
def topological_ordering(*vertices)
  PartialOrder[self, *vertices].sort!.map(&:vertex)
end

Protected Instance Methods

insert_edge(edge) click to toggle source
Calls superclass method Tangle::BaseGraphProtected#insert_edge
# File lib/tangle/directed/acyclic/graph.rb, line 19
def insert_edge(edge)
  raise CyclicError if successor?(edge.head, edge.tail) ||
                       predecessor?(edge.tail, edge.head)

  super
end