Warning

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

networkx.generators.classic.cycle_graph

cycle_graph(n, create_using=None)[source]

Returns the cycle graph \(C_n\) of cyclically connected nodes.

\(C_n\) is a path with its two end-nodes connected.

Parameters:
  • n (int or iterable container of nodes) – If n is an integer, nodes are from range(n). If n is a container of nodes, those nodes appear in the graph.
  • create_using (NetworkX graph constructor, optional (default=nx.Graph)) – Graph type to create. If graph instance, then cleared before populated.

Notes

If create_using is directed, the direction is in increasing order.