4.1.8. networkx.classes.function.add_path

networkx.classes.function.add_path(G, nodes, **attr)[source]

Add a path to the Graph G.

Parameters:

nodes : iterable container

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

attr : keyword 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)