MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / from_edgelist

Function from_edgelist

easygraph/convert.py:263–286  ·  view source on GitHub ↗

Returns a graph from a list of edges. Parameters ---------- edgelist : list or iterator Edge tuples create_using : EasyGraph graph constructor, optional (default=eg.Graph) Graph type to create. If graph instance, then cleared before populated. Examples ------

(edgelist, create_using=None)

Source from the content-addressed store, hash-verified

261
262
263def from_edgelist(edgelist, create_using=None):
264 """Returns a graph from a list of edges.
265
266 Parameters
267 ----------
268 edgelist : list or iterator
269 Edge tuples
270
271 create_using : EasyGraph graph constructor, optional (default=eg.Graph)
272 Graph type to create. If graph instance, then cleared before populated.
273
274 Examples
275 --------
276 >>> edgelist = [(0, 1)] # single edge (0,1)
277 >>> G = eg.from_edgelist(edgelist)
278
279 or
280
281 >>> G = eg.Graph(edgelist) # use Graph constructor
282
283 """
284 G = eg.empty_graph(0, create_using)
285 G.add_edges_from(edgelist)
286 return G
287
288
289def to_networkx(g: "Union[Graph, DiGraph]") -> "Union[nx.Graph, nx.DiGraph]":

Callers 1

to_easygraph_graphFunction · 0.85

Calls 1

add_edges_fromMethod · 0.45

Tested by

no test coverage detected