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.



17
18
19
# File 'lib/tangle/directed/acyclic/partial_order.rb', line 17

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.



12
13
14
15
# File 'lib/tangle/directed/acyclic/partial_order.rb', line 12

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