Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
gremlin> g = TinkerFactory.createClassic()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V.out.out.match('a',
gremlin> g.of().as('b').out('created').as('a'),
gremlin> g.of().as('a').in('knows').as('b'))
The provided traversal set contains a cycle due to 'a'
Display stack trace? [yN]
gremlin> 1+2
gremlin> 1+2
groovysh_parse: 5: expecting ')', found '1' @ line 5, column 1.
gremlin> g.V.match('a',
gremlin> g.of().as('a').out('created').has('name','lop').as('b'),
gremlin> g.of().as('b').in('created').has('age', 29).as('c')).select{it.value('name')}
==>[a:marko, b:lop, c:marko]
==>[a:josh, b:lop, c:marko]
==>[a:peter, b:lop, c:marko]
gremlin>
gremlin>
gremlin>
gremlin> g.V.match('a',
g.V.as('x').both.groupCount('m'){it.value('name')}.jump('x',10).cap('m')
OR
g.V.as('x').both.groupCount{it.value('name')}.as('m').jump('x',10).cap('m')
gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> myVertices = g.v(1,2,3).toList() // here are my vertices as a collection
==>v[1]
==>v[2]
==>v[3]
gremlin> myVertices._().out // what are the adjacent vertices to this collection?
==>v[2]
==>v[4]
==>v[3]
Testing: [Neo4jGraphStep@x, VertexStep(OUT), GroupCountStep@a, JumpStep(x,2), SideEffectCapStep(a)]
[Neo4jGraphStep@x, VertexStep(OUT), GroupCountStep@a, VertexStep(OUT), GroupCountStep@a, SideEffectCapStep(a)]
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class GraphComputerTest extends AbstractGremlinTest {
@Test
public void shouldComputeSomeBusiness() {
// temporary placetraverser as the test previously in here has been moved to FeatureSupportTest.
}
}
public class GraphComputerTest extends AbstractGremlinTest {
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_COMPUTER)
public void shouldHaveStandardStringRepresentation() {
final GraphComputer computer = g.compute();
assertEquals(StringFactory.computerString(computer), computer.toString());
}
@Test
gremlin> result = g.compute().program(LambdaVertexProgram.build().
gremlin> execute(new GSTriConsumer("a.property('counter', c.isInitialIteration() ? 1 : ++a.value('counter'))")).
gremlin> terminate(new GSPredicate('a.iteration > 9')).
gremlin> elementComputeKeys('counter',VARIABLE).create()).submit().get()
==>result[tinkergraph[vertices:6 edges:6],sideEffects[size:0]]
gremlin> result.graph.V.counter
==>10
==>10
==>10
==>10
package com.tinkerpop.gremlin.structure.strategy;
import com.tinkerpop.gremlin.AbstractGremlinTest;
import com.tinkerpop.gremlin.LoadGraphWith;
import com.tinkerpop.gremlin.structure.Edge;
import com.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import java.util.NoSuchElementException;
import java.util.function.Predicate;
~/software/tinkerpop/tinkerpop3/gremlin-console/target/gremlin-console-3.0.0-SNAPSHOT-standalone$ bin/gremlin.sh
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: server
plugin activated: utilities
gremlin> :install com.tinkerpop giraph-gremlin 3.0.0-SNAPSHOT==>loaded: [com.tinkerpop, giraph-gremlin, 3.0.0-SNAPSHOT] - restart the console to use [giraph]
gremlin> :q
~/software/tinkerpop/tinkerpop3/gremlin-console/target/gremlin-console-3.0.0-SNAPSHOT-standalone$ bin/gremlin.sh