add_path

add_path(G_to_add_to, nodes_for_path, **attr)[source]

Add a path to the Graph G_to_add_to.

Parameters
G_to_add_tograph

A NetworkX graph

nodes_for_pathiterable container

A container of nodes. A path will be constructed from the nodes (in order) and added to the graph.

attrkeyword arguments, optional (default= no attributes)

Attributes to add to every edge in path.

See also

add_star, add_cycle

Examples

>>> G = nx.Graph()
>>> nx.add_path(G, [0, 1, 2, 3])
>>> nx.add_path(G, [10, 11, 12], weight=7)