Method: GraphLab::Graph#addEdgeForGraph

Defined in:
lib/graphlab.rb

#addEdgeForGraph(v1, v2) ⇒ Object

to add edge from v1 to v2 - directed graph



289
290
291
292
293
294
295
296
297
298
299
# File 'lib/graphlab.rb', line 289

def addEdgeForGraph(v1,v2)
  raise "Value must be a Vertex!" if v1.class != GraphLab::Vertex
  raise "Value must be a Vertex!" if v2.class != GraphLab::Vertex
  raise "Vertex must be in the graph" if !include?(v1)
  raise "Vertex must be in the graph" if !include?(v2)
  raise "Vertex "+v2+" already adjacent vertex of "+v1+" in the graph!" if v1.adjList.include?(v2)
  raise "cannot add edge to itself" if v1 == v2
  if(v1.class == GraphLab::Vertex && v2.class == GraphLab::Vertex && include?(v1) && include?(v2))
    v1.addEdge(v2)
  end
end