Method: NetworkX::Graph#initialize

Defined in:
lib/networkx/graph.rb

#initialize(**graph_attrs) ⇒ Graph

Constructor for initializing graph

Examples:

Initialize a graph with attributes 'type' and 'name'

graph = NetworkX::Graph.new(name: "Social Network", type: "undirected")

Parameters:

  • graph_attrs (Hash{ Object => Object })

    the graph attributes in a hash format



16
17
18
19
20
# File 'lib/networkx/graph.rb', line 16

def initialize(**graph_attrs)
  @nodes = {}
  @adj = {}
  @graph = graph_attrs
end