generate_edgelist#

generate_edgelist(G, delimiter=' ', data=True)[source]#

Generate a single line of the bipartite graph G in edge list format.

Parameters:
GNetworkX graph

The graph is assumed to have node attribute part set to 0,1 representing the two graph parts

delimiterstring, optional

Separator for node labels

databool or list of keys

If False generate no edge data. If True use a dictionary representation of edge data. If a list of keys use a list of data values corresponding to the keys.

Returns:
linesstring

Lines of data in adjlist format.

Examples

>>> from networkx.algorithms import bipartite
>>> G = nx.path_graph(4)
>>> G.add_nodes_from([0, 2], bipartite=0)
>>> G.add_nodes_from([1, 3], bipartite=1)
>>> G[1][2]["weight"] = 3
>>> G[2][3]["capacity"] = 12
>>> for line in bipartite.generate_edgelist(G, data=False):
...     print(line)
0 1
2 1
2 3
>>> for line in bipartite.generate_edgelist(G):
...     print(line)
0 1 {}
2 1 {'weight': 3}
2 3 {'capacity': 12}
>>> for line in bipartite.generate_edgelist(G, data=["weight"]):
...     print(line)
0 1
2 1 3
2 3