networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
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.

Default keys are generated using the method new_edge_key() . This method can be overridden by subclassing the base class and providing a custom new_edge_key() method.

Parameters

ebunch_to_add : container of edges

Each edge given in the container will be added to the graph. The edges can be:

  • 2-tuples (u, v) or

  • 3-tuples (u, v, d) for an edge data dict d, or

  • 3-tuples (u, v, k) for not iterable key k, or

  • 4-tuples (u, v, k, d) for an edge with data and key k

attr : keyword arguments, optional

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

Returns

A list of edge keys assigned to the edges in `ebunch`.

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.multidigraph.MultiDiGraph.remove_edge networkx.classes.multidigraph.MultiDiGraph networkx.classes.multigraph.MultiGraph.remove_edge networkx.classes.multidigraph.MultiDiGraph.add_edge networkx.classes.multigraph.MultiGraph networkx.classes.multigraph.MultiGraph.add_edge networkx.classes.multigraph.MultiGraph.to_undirected networkx.classes.multigraph.MultiGraph.remove_edges_from

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/multigraph.py#511
type: <class 'function'>
Commit: