Class: GraphUtils::DirectedEdge

Inherits:
Object
  • Object
show all
Defined in:
lib/GraphUtils.rb

Overview

Represents a directed edge in a graph.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(startVertex, endVertex) ⇒ DirectedEdge

Returns a new instance of DirectedEdge.



206
207
208
209
# File 'lib/GraphUtils.rb', line 206

def initialize(startVertex, endVertex)
    @startVertex = startVertex
    @endVertex = endVertex
end

Instance Attribute Details

#endVertexObject (readonly)

Returns the value of attribute endVertex.



205
206
207
# File 'lib/GraphUtils.rb', line 205

def endVertex
  @endVertex
end

#startVertexObject (readonly)

Returns the value of attribute startVertex.



205
206
207
# File 'lib/GraphUtils.rb', line 205

def startVertex
  @startVertex
end

Instance Method Details

#==(edge) ⇒ Object



215
216
217
# File 'lib/GraphUtils.rb', line 215

def ==(edge)
    edge.kind_of?(DirectedEdge) and @startVertex == edge.startVertex and @endVertex == edge.endVertex
end

#include?(v) ⇒ Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/GraphUtils.rb', line 211

def include?(v)
    v == startVertex or v == endVertex
end

#to_sObject



219
220
221
# File 'lib/GraphUtils.rb', line 219

def to_s
    @startVertex.to_s + " -> " + @endVertex.to_s
end