- complete_graph(n, create_using=None)#
Return the complete graph
K_nwith n nodes.
A complete graph on
nnodes means that all pairs of distinct nodes have an edge connecting them.
- 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.
>>> G = nx.complete_graph(9) >>> len(G) 9 >>> G.size() 36 >>> G = nx.complete_graph(range(11, 14)) >>> list(G.nodes()) [11, 12, 13] >>> G = nx.complete_graph(4, nx.DiGraph()) >>> G.is_directed() True
Additional backends implement this function
cugraph : GPU-accelerated backend.