NetworkX

Previous topic

networkx.expected_degree_graph

Next topic

networkx.degree_sequence_tree

Quick search

networkx.havel_hakimi_graph

havel_hakimi_graph(deg_sequence)

Return a simple graph with given degree sequence, constructed using the Havel-Hakimi algorithm.

  • deg_sequence: degree sequence, a list of integers with each entry

    corresponding to the degree of a node (need not be sorted). A non-graphical degree sequence (not sorted). A non-graphical degree sequence (i.e. one not realizable by some simple graph) raises an Exception.

The Havel-Hakimi algorithm constructs a simple graph by successively connecting the node of highest degree to other nodes of highest degree, resorting remaining nodes by degree, and repeating the process. The resulting graph has a high degree-associativity. Nodes are labeled 1,.., len(deg_sequence), corresponding to their position in deg_sequence.

See Theorem 1.4 in [chartrand-graphs-1996]. This algorithm is also used in the function is_valid_degree_sequence.

References:

[chartrand-graphs-1996] G. Chartrand and L. Lesniak, “Graphs and Digraphs”,
Chapman and Hall/CRC, 1996.