path_graph#

path_graph(n, create_using=None)[source]#

Returns the Path graph P_n of linearly connected nodes.

Parameters:
nint or iterable

If an integer, nodes are 0 to n - 1. If an iterable of nodes, in the order they appear in the path.

create_usingNetworkX graph constructor, optional (default=nx.Graph)

Graph type to create. If graph instance, then cleared before populated.