Skip to content

Degree Distribution Generator

mbroecheler edited this page Sep 28, 2012 · 1 revision

DegreeDistributionGenerator generates a synthetic network according to a specified in-degree and (optionally) out-degree distribution.

The following example generates a synthetic graph with 100 vertices and 1000 edges where the out-degree distribution is defined by a power law distribution with gamma value = 2.1, thereby generating a scale-free network. Since the in-degree distribution is not defined, the in-degree is equal to the out-degree.

TinkerGraph graph = new TinkerGraph();
for (int i=0;i<100;i++) graph.addVertex(i);
DistributionGenerator generator = new DistributionGenerator("knows");
generator.setOutDistribution(new PowerLawDistribution(2.1));
int numEdges = generator.generate(graph,1000);

As with all generators, the constructor takes the edge label of the generated edges and optionally an EdgeAnnotator implementation which can be used to annotate the edges with properties.

Additionally, we could define an in-degree distribution. In the example below, the in-degree distribution is defined by a normal distribution with standard deviation = 4.

TinkerGraph graph = new TinkerGraph();
for (int i=0;i<100;i++) graph.addVertex(i);

DistributionGenerator generator = new DistributionGenerator("knows");
generator.setOutDistribution(new PowerLawDistribution(2.1));
generator.setInDistribution(new NormalDistribution(4));
int numEdges = generator.generate(graph,1000);