NetworkX

Previous topic

networkx.Graph.__iter__

Next topic

networkx.Graph.edges_iter

Quick search

networkx.Graph.edges

Graph.edges(nbunch=None, data=False)

Return a list of edges.

Parameters:

nbunch : list, iterable

A container of nodes that will be iterated through once (thus it should be an iterator or be iterable). Each element of the container should be a valid node type: any hashable type except None. If nbunch is None, return all edges in the graph. Nodes in nbunch that are not in the graph will be (quietly) ignored.

data : bool

Return two tuples (u,v) (False) or three-tuples (u,v,data) (True)

Returns:

Edges that are adjacent to any node in nbunch, :

or a list of all edges if nbunch is not specified. :

Examples

>>> G=nx.path_graph(4)
>>> G.edges()
[(0, 1), (1, 2), (2, 3)]
>>> G.edges(data=True) # default edge data is 1
[(0, 1, 1), (1, 2, 1), (2, 3, 1)]