Class: Tangle::Directed::Acyclic::PartialOrder

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/tangle/directed/acyclic/partial_order.rb

Overview

Implement a Partial Order for vertices in a DAG.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#vertexObject (readonly)

Returns the value of attribute vertex.



19
20
21
# File 'lib/tangle/directed/acyclic/partial_order.rb', line 19

def vertex
  @vertex
end

Class Method Details

.[](graph, *vertices) ⇒ Object

Wrap a set of vertices, or all vertices, in a graph in a parial ordering, such that the elements in the returned set are comparable by u <= v iff v is an ancestor of u.



14
15
16
17
# File 'lib/tangle/directed/acyclic/partial_order.rb', line 14

def self.[](graph, *vertices)
  vertices = graph.vertices if vertices.empty?
  vertices.map { |vertex| new(graph, vertex) }
end