Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.generators.classic.path_graph

path_graph(n, create_using=None)[source]

Returns the Path graph P_n of linearly connected nodes.

Parameters
  • n (int or iterable) – If an integer, node labels are 0 to n with center 0. If an iterable of nodes, the center is the first.

  • create_using (NetworkX graph constructor, optional (default=nx.Graph)) – Graph type to create. If graph instance, then cleared before populated.