User:AbelianThoreau/sandbox

Enumerating Graphs with given Degree Sequence
Given a degree sequence d=(d1, d2, ..., dn) one can enumerate all the graphs with degree sequence d using an algorithm. One such algorithm given by Blitzstein and Diaconis is as follows;

INPUT: a graphical sequence d=(d1, d2, ..., dn).
 * 1) Let E be an empty list of edges.
 * 2) If d = 0, terminate with output E.
 * 3) Choose the least i with di a minimal positive entry.
 * 4) Compute the candidate list J={j≠i : {i,j} ∉ E and (d1, d2, ...,di &minus; 1,..., dj &minus; 1, ..., dn)  is graphical.}
 * 5) Pick j ∈ J with probability proportional to its degree in d.
 * 6) Add edge {i,j} to E and update d to (d1, d2, ...,di &minus; 1,..., dj &minus; 1, ..., dn)
 * 7) Repeat steps 4-6 until the degree of i is 0.
 * 8) Return to step 2.

OUTPUT: E

This algorithm generates a random graph with the given degree sequence. Running the algorithm repeatedly will generate all graphs with degree sequence d.