Graph language "Gremlin"
TinkerPop3 Documentation
"A graph’s structure is the topology formed by the explicit references between its vertices, edges, and properties. A vertex has incident edges. A vertex is adjacent to another vertex if they share an incident edge. A property is attached to an element and an element has a set of properties. A property is a key/value pair, where the key is always a character String. The graph structure API of TinkerPop3 provides the methods necessary to create such a structure. The TinkerPop graph previously diagrammed can be created with the following Java 8 code. Note that this graph is available as an in-memory TinkerGraph using TinkerFactory.createClassic()."
Graph graph = TinkerGraph.open(); (1) Vertex marko = graph.addVertex(T.label, "person", T.id, 1, "name", "marko", "age", 29); (2) Vertex vadas = graph.addVertex(T.label, "person", T.id, 2, "name", "vadas", "age", 27); Vertex lop = graph.addVertex(T.label, "software", T.id, 3, "name", "lop", "lang", "java"); Vertex josh = graph.addVertex(T.label, "person", T.id, 4, "name", "josh", "age", 32); Vertex ripple = graph.addVertex(T.label, "software", T.id, 5, "name", "ripple", "lang", "java"); Vertex peter = graph.addVertex(T.label, "person", T.id, 6, "name", "peter", "age", 35); marko.addEdge("knows", vadas, T.id, 7, "weight", 0.5f); (3) marko.addEdge("knows", josh, T.id, 8, "weight", 1.0f); marko.addEdge("created", lop, T.id, 9, "weight", 0.4f); josh.addEdge("created", ripple, T.id, 10, "weight", 1.0f); josh.addEdge("created", lop, T.id, 11, "weight", 0.4f); peter.addEdge("created", lop, T.id, 12, "weight", 0.2f);
Alternative, a bit simpler to use, graph query language is Cypher from Neo4j.
graph databases - Neo4j - Cypher vs Gremlin query language - Stack Overflow
client.execute('g.V().has("name", name)', { name: 'Alice' }, (err, results) => { if (err) return console.error(err); console.log(results); })
The Gremlin Graph Traversal Language @ SlideShare
Azure Cosmos DB: NoSQL capabilities everyone should know about | Build 2017 | Channel 9
How to build globally-distributed, fast, billion-user applications with Azure Cosmos DB | Build 2017 | Channel 9
No comments:
Post a Comment