easygraph.functions.graph_generator.classic module#

easygraph.functions.graph_generator.classic.complete_graph(n, create_using=None)[source]#

Return the complete graph K_n with n nodes.

A complete graph on n nodes means that all pairs of distinct nodes have an edge connecting them.

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 (EasyGraph graph constructor, optional (default=eg.Graph)) – Graph type to create. If graph instance, then cleared before populated.

Examples

>>> G = eg.complete_graph(9)
>>> len(G)
9
>>> G.size()
36
>>> G = eg.complete_graph(range(11, 14))
>>> list(G.nodes())
[11, 12, 13]
>>> G = eg.complete_graph(4, eg.DiGraph())
>>> G.is_directed()
True
easygraph.functions.graph_generator.classic.empty_graph(n=0, create_using=None, default=<class 'easygraph.classes.graph.Graph'>)[source]#
easygraph.functions.graph_generator.classic.path_graph(n, create_using=None)[source]#