Skip to content

Instantly share code, notes, and snippets.

@dkuppitz
Created January 18, 2017 15:16
Show Gist options
  • Save dkuppitz/3828633eb0483ed62f4ef42b7827ae8d to your computer and use it in GitHub Desktop.
Save dkuppitz/3828633eb0483ed62f4ef42b7827ae8d to your computer and use it in GitHub Desktop.
gremlin> createGraph = { numV, numE ->
......1> graph = TinkerGraph.open()
......2> rand = new Random()
......3> vertices = []
......4> (1..numV).each {vertices << graph.addVertex()}
......5> (1..numE).each {
......6> v1 = vertices[rand.nextInt() % numV]
......7> v2 = vertices[rand.nextInt() % numV]
......8> v1.addEdge("link", v2)
......9> }
.....10> graph
.....11> }
==>groovysh_evaluate$_run_closure1@15fc442
gremlin> g = createGraph(10, 5).traversal()
==>graphtraversalsource[tinkergraph[vertices:10 edges:5], standard]
gremlin> g.V().repeat(both().simplePath()).emit().count()
==>12
gremlin> g = createGraph(10, 10).traversal()
==>graphtraversalsource[tinkergraph[vertices:10 edges:10], standard]
gremlin> g.V().repeat(both().simplePath()).emit().count()
==>162
gremlin> g = createGraph(10, 20).traversal()
==>graphtraversalsource[tinkergraph[vertices:10 edges:20], standard]
gremlin> g.V().repeat(both().simplePath()).emit().count()
==>4946
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment