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.

(Source code, png)

nint 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. Warning: n is not checked for duplicates and if present the resulting graph may not be as desired. Make sure you have no duplicates.

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

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


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

Additional backends implement this function

cugraph : GPU-accelerated backend.