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.algorithms.community.kclique.k_clique_communities networkx.classes.multigraph.MultiGraph.add_edges_from networkx.algorithms.connectivity.edge_kcomponents.k_edge_subgraphs networkx.classes.graph.Graph.update networkx.classes.function.is_negatively_weighted networkx.convert.to_dict_of_dicts networkx.classes.digraph.DiGraph.add_edges_from networkx.classes.graph.Graph.to_undirected networkx.algorithms.connectivity.edge_kcomponents.k_edge_components networkx.classes.graph.Graph networkx.algorithms.graph_hashing.weisfeiler_lehman_graph_hash networkx.classes.graph.Graph.add_edge networkx.classes.graph.Graph.add_edges_from networkx.algorithms.traversal.breadth_first_search.bfs_predecessors networkx.classes.graph.Graph.add_weighted_edges_from networkx.algorithms.assortativity.correlation.numeric_assortativity_coefficient networkx.algorithms.bipartite.projection.projected_graph networkx.algorithms.tree.recognition.is_tree networkx.algorithms.assortativity.correlation.attribute_assortativity_coefficient networkx.algorithms.connectivity.edge_augmentation.k_edge_augmentation networkx.algorithms.link_prediction.within_inter_cluster networkx.algorithms.tree.recognition.is_forest networkx.algorithms.link_prediction.ra_index_soundarajan_hopcroft networkx.classes.digraph.DiGraph.add_edge networkx.algorithms.graph_hashing.weisfeiler_lehman_subgraph_hashes networkx.algorithms.traversal.breadth_first_search.bfs_successors networkx.classes.reportviews.OutEdgeView.data networkx.algorithms.connectivity.edge_kcomponents.EdgeComponentAuxGraph

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