edu.stanford.math.plex4.graph.random
public class PrescribedDegrees extends GraphInstanceGenerator
GraphInstanceGenerator.ImplementationType
Modifier and Type | Field and Description |
---|---|
protected int[] |
degreeSequence |
protected int |
numNodes |
graphImplementation, implementationType
Constructor and Description |
---|
PrescribedDegrees(int[] degreeSequence) |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
erdosGallaiCriteria(int[] d,
int k)
Checks the Erdos-Gallai criteria for a particular value of k.
|
AbstractUndirectedGraph |
generate()
Implements "Sequential Algorithm For Random Graph with Given Degrees"
from "A SEQUENTIAL IMPORTANCE SAMPLING ALGORITHM FOR GENERATING RANDOM
GRAPHS WITH PRESCRIBED DEGREES" By Joseph Blitzstein and Persi Diaconis
|
protected int[] |
getCandidateList(int[] d,
int i,
AbstractUndirectedGraph graph)
Computes the set of j!=i such that multiminus(d,i,j) is graphical and
(i,j) is not already an edge.
|
protected double[] |
getProbabilityPartition(int[] d)
Constructs a partition p of [0,1] such that p[i+1]-p[i] is proportional
to the degree of node i in the list d.
|
static boolean |
isGraphical(int[] d)
Determines if a degree sequence is realizable using the Erdos-Gallai
Criteria
|
static int |
minPositivePosition(int[] arr)
Returns the first index of the smallest positive element or -1 if there
are no positive entries
|
protected int[] |
multiMinus(int[] ds,
int i,
int j)
Returns the array ds with 1 subtracted from the i-th element and 1
subtracted from the j-th element.
|
java.lang.String |
toString() |
protected int |
whichSegmentHasX(double[] p,
double x)
Returns the segment i such that x is in [p[i],p[i+1]].
|
initializeGraph, setImplementationType
public AbstractUndirectedGraph generate()
generate
in class GraphInstanceGenerator
argd
- protected static boolean erdosGallaiCriteria(int[] d, int k)
d
- k
- public static boolean isGraphical(int[] d)
degreeSequence
- protected int whichSegmentHasX(double[] p, double x)
p
- x
- protected int[] getCandidateList(int[] d, int i, AbstractUndirectedGraph graph)
d
- i
- protected double[] getProbabilityPartition(int[] d)
d
- degree sequenceprotected int[] multiMinus(int[] ds, int i, int j)
ds
- i
- j
- public static int minPositivePosition(int[] arr)
arr
- public java.lang.String toString()
toString
in class java.lang.Object