Created
May 17, 2018 21:24
-
-
Save sambos/765a0f990bd8371bdc54841364ea9d8d to your computer and use it in GitHub Desktop.
Tinkerpop graph exampl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.tinkerpop.gremlin.structure.T | |
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph | |
import org.apache.tinkerpop.gremlin.structure.Vertex | |
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils | |
object TinkerpopGraphTest { | |
def main(args: Array[String]): Unit = { | |
val graph: org.apache.tinkerpop.gremlin.structure.Graph = TinkerGraph.open() | |
val marko: Vertex = graph.addVertex(T.label, "person", T.id, "1", "name", "marko", "age", "29") | |
val vadas:Vertex = graph.addVertex(T.label, "person", T.id, "2", "name", "vadas", "age", "27") | |
val n = new Node() | |
n.nodeId = "n1" | |
n.appName = "tapp" | |
val test:Vertex = graph.addVertex(T.label, "person", T.id, "3", "node",n) | |
marko.addEdge("knows", vadas, T.id, "7", "weight", "0.5f","weight", "0.5f") | |
val node:Node = graph.vertices("3").next().property("node").value() | |
println(node.appName) | |
println(IteratorUtils.count(graph.vertices())) | |
println(IteratorUtils.count(graph.edges("71"))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment