Graph.__init__(incoming_graph_data=None, **attr)[source]

Initialize a graph with edges, name, or graph attributes

  • incoming_graph_data (input graph (optional, default: None)) – Data to initialize graph. If None (default) an empty graph is created. The data can be any format that is supported by the to_nx_graph() function, currently including edge list, dict of dicts, dict of lists, NetworkX graph, NumPy matrix or 2d ndarray, Pandas DataFrame, SciPy sparse matrix, or a graphscope graph.

  • attr (keyword arguments, optional (default= no attributes)) – Attributes to add to graph as key=value pairs.


>>> G = nx.Graph()  # or DiGraph, etc
>>> G = nx.Graph(name='my graph')
>>> e = [(1, 2), (2, 3), (3, 4)]  # list of edges
>>> G = nx.Graph(e)

Arbitrary graph attribute pairs (key=value) may be assigned

>>> G = nx.Graph(e, day="Friday")
>>> G.graph
{'day': 'Friday'}

graphscope graph can convert to nx.Graph throught incomming_graph_data.

>>> g = Graph()
>>> g.load_from(vertices={}, edges={})
>>> G = nx.Graph(g)  # or DiGraph, etc