Skip to content

Instantly share code, notes, and snippets.

@xhochy
Created January 15, 2013 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xhochy/4538077 to your computer and use it in GitHub Desktop.
Save xhochy/4538077 to your computer and use it in GitHub Desktop.
Generate graph communities and annotate vertices so that each vertex has its community as a property
package com.xhochy
import com.tinkerpop.blueprints.impls.tg.TinkerGraph
import com.tinkerpop.furnace.generators.{ CommunityGenerator, EdgeAnnotator, NormalDistribution, PowerLawDistribution, VertexAnnotator }
object Generator {
def main(args: Array[String]) = {
val graph = new TinkerGraph
Range(0, 100).foreach(graph.addVertex(_))
val generator = new CommunityGenerator("edge", EdgeAnnotator.NONE, VertexAnnotator.COPY_CONTEXT)
generator.setCommunityDistribution(new NormalDistribution(3));
generator.setDegreeDistribution(new PowerLawDistribution(2.3));
generator.setCrossCommunityPercentage(0.1);
val numEdges = generator.generate(graph, 10, 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment