networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
to_pandas_edgelist(G, source='source', target='target', nodelist=None, dtype=None, order=None, edge_key=None)

Parameters

G : graph

The NetworkX graph used to construct the Pandas DataFrame.

source : str or int, optional

A valid column name (string or integer) for the source nodes (for the directed case).

target : str or int, optional

A valid column name (string or integer) for the target nodes (for the directed case).

nodelist : list, optional

Use only nodes specified in nodelist

dtype : dtype, default None

Use to create the DataFrame. Data type to force. Only a single dtype is allowed. If None, infer.

order : None

An unused parameter mistakenly included in the function.

deprecated

This is deprecated and will be removed in NetworkX v3.0.

edge_key : str or int or None, optional (default=None)

A valid column name (string or integer) for the edge keys (for the multigraph case). If None, edge keys are not stored in the DataFrame.

Returns

df : Pandas DataFrame

Graph edge list

Returns the graph edge list as a Pandas DataFrame.

Examples

>>> G = nx.Graph(
...  [
...  ("A", "B", {"cost": 1, "weight": 7}),
...  ("C", "E", {"cost": 9, "weight": 10}),
...  ]
... )
... df = nx.to_pandas_edgelist(G, nodelist=["A", "C"])
... df[["source", "target", "cost", "weight"]] source target cost weight 0 A B 1 7 1 C E 9 10
>>> G = nx.MultiGraph([('A', 'B', {'cost': 1}), ('A', 'B', {'cost': 9})])
... df = nx.to_pandas_edgelist(G, nodelist=['A', 'C'], edge_key='ekey')
... df[['source', 'target', 'cost', 'ekey']] source target cost ekey 0 A B 1 0 1 A B 9 1
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.convert_matrix.to_pandas_edgelist networkx.convert_matrix.from_pandas_edgelist

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/convert_matrix.py#217
type: <class 'function'>
Commit: