networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersBackRef
add_edges_from(self, ebunch_to_add, **attr)

Notes

Adding the same edge twice has no effect but any edge data will be updated when each duplicate edge is added.

Edge attributes specified in an ebunch take precedence over attributes specified via keyword arguments.

Parameters

ebunch_to_add : container of edges

Each edge given in the container will be added to the graph. The edges must be given as 2-tuples (u, v) or 3-tuples (u, v, d) where d is a dictionary containing edge data.

attr : keyword arguments, optional

Edge data (or labels or objects) can be assigned using keyword arguments.

Add all the edges in ebunch_to_add.

See Also

add_edge

add a single edge

add_weighted_edges_from

convenient way to add weighted edges

Examples

>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
... G.add_edges_from([(0, 1), (1, 2)]) # using a list of edge tuples
... e = zip(range(0, 3), range(1, 4))
... G.add_edges_from(e) # Add the path graph 0-1-2-3

Associate data to edges

>>> G.add_edges_from([(1, 2), (2, 3)], weight=3)
... G.add_edges_from([(3, 4), (1, 4)], label="WN2898")
See :

Back References

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

networkx.classes.digraph.DiGraph networkx.algorithms.dag.transitive_reduction networkx.algorithms.traversal.breadth_first_search.descendants_at_distance networkx.drawing.nx_pylab.draw_networkx_edges networkx.algorithms.flow.mincost.max_flow_min_cost networkx.classes.digraph.DiGraph.to_undirected networkx.algorithms.centrality.reaching.local_reaching_centrality networkx.linalg.modularitymatrix.directed_modularity_matrix networkx.classes.digraph.DiGraph.add_edge

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/classes/digraph.py#646
type: <class 'function'>
Commit: