Method: RGL::DirectedAdjacencyGraph#initialize

Defined in:
lib/rgl/adjacency.rb

#initialize(edgelist_class = Set, *other_graphs) ⇒ DirectedAdjacencyGraph

The new empty graph has as its edgelist class the given class. The default edgelist class is Set, to ensure set semantics for edges and vertices.

If other graphs are passed as parameters their vertices and edges are added to the new graph.

Parameters:

  • edgelist_class (Class) (defaults to: Set)
  • other_graphs (Array[Graph])


39
40
41
42
43
44
45
46
# File 'lib/rgl/adjacency.rb', line 39

def initialize(edgelist_class = Set, *other_graphs)
  @edgelist_class = edgelist_class
  @vertices_dict = Hash.new
  other_graphs.each do |g|
    g.each_vertex { |v| add_vertex v }
    g.each_edge { |v, w| add_edge v, w }
  end
end