The document provides examples of using the TinkerGraph graph database and Gremlin traversal language. It shows how to:
1) Create a TinkerGraph, add vertices and edges, and get basic graph information and elements.
2) Perform common traversals in Gremlin such as getting vertex neighbors, paths, filtering, transforming properties, and looping through connections.
3) Demonstrate more complex multi-step traversals using pipes and filters, conditional branching, and other Gremlin steps and predicates.
Take control of your SAP testing with UiPath Test Suite
An Introduction to Tinkerpop
1.
2.
3.
4.
5.
6.
7.
8.
9.
10. // An Exapmle of TinkerGraph
Graph graph = new TinkerGraph();
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
a.setProperty("name", "marko");
b.setProperty("name", "peter");
Edge e = graph.addEdge(null, a, b, "knows");
// marko--knows-->peter
11. public void testIteratingGraph() {
Graph graph = TinkerGraphFactory.createTinkerGraph();
System.out.println("Vertices of " + graph);
for (Vertex vertex : graph.getVertices()) {
System.out.println(vertex);
}
System.out.println("Edges of " + graph);
for (Edge edge : graph.getEdges()) {
System.out.println(edge);
}
Vertices of tinkergraph[vertices:6 edges:6]
}
v[3]
v[2]
...
Edges of tinkergraph[vertices:6 edges:6]
e[10][4-created->5]
e[7][1-knows->2]
...
12.
13.
14.
15. {
"a" : 1,
http://localhost:8182/graphs/toygraph/toy-
"b" : {
traversal?
"a" : "marko",
a=1&b.a=marko&b.b=true&b.c.a=peter&c=[mark "b" : true,
o,povel] "c" : {
"a" : "peter"
}
}
"c" : ["marko","povel"]
}