Class: RGL::Edge::UnDirectedEdge

Inherits:
DirectedEdge show all
Defined in:
lib/rgl/base.rb

Overview

An undirected edge is simply an undirected pair (source, target) used in undirected graphs. UnDirectedEdge == UnDirectedEdge

Instance Attribute Summary

Attributes inherited from DirectedEdge

#source, #target

Instance Method Summary collapse

Methods inherited from DirectedEdge

#<=>, [], #[], #initialize, #reverse, #to_a

Constructor Details

This class inherits a constructor from RGL::Edge::DirectedEdge

Instance Method Details

#eql?(edge) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/rgl/base.rb', line 71

def eql?(edge)
  super or (target == edge.source and source == edge.target)
end

#hashObject



75
76
77
# File 'lib/rgl/base.rb', line 75

def hash
  source.hash ^ target.hash
end

#to_sObject

UnDirectedEdge.to_s == “(1=2)”



80
# File 'lib/rgl/base.rb', line 80

def to_s; "(#{source}=#{target})"; end