-
Notifications
You must be signed in to change notification settings - Fork 0
Community Generator
CommunityGenerator
generates a synthetic network with communities, that is, densely connected sub-networks that are loosely connected to one another.
The following example generates a synthetic graph with 100 vertices, 10 communities and 1000 edges where the community size distribution is defined by a normal distribution with standard deviation = 3 and the vertex degree distribution is defined by a power law distribution with gamma value = 2.3. In addition, we specify that 10 percent of all edges should cross communities, i.e. connect a vertex in one community with a vertex in another. That means that 90 percent of all edges connect vertices in the same community.
TinkerGraph graph = new TinkerGraph();
for (int i=0;i<100;i++) graph.addVertex(i);
CommunityGenerator generator = new CommunityGenerator("knows");
generator.setCommunityDistribution(new NormalDistribution(3));
generator.setDegreeDistribution(new PowerLawDistribution(2.3));
generator.setCrossCommunityPercentage(0.1);
int numEdges = generator.generate(graph,10,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.