Closed ktschmidt closed 3 years ago
Started looking at this one.
@Test
public void testPathFrom() {
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
Vertex c1 = this.sqlgGraph.addVertex(T.label, "C", "name", "c1");
a1.addEdge("ab", b1);
b1.addEdge("bc", c1);
this.sqlgGraph.tx().commit();
List<Path> paths = this.sqlgGraph.traversal().V().hasLabel("A").out("ab").as("b").out("bc").path().toList();
System.out.println(paths);
paths = this.sqlgGraph.traversal().V().hasLabel("A").out("ab").as("b").out("bc").path().from("b").toList();
System.out.println(paths);
GraphTraversal<Vertex, Path> t = this.sqlgGraph.traversal()
.V().hasLabel("A").as("a")
.out("ab").select("a").as("start")
.path();
printTraversalForm(t);
paths = t.toList();
System.out.println(paths);
Assert.assertEquals(1, paths.size());
Path path = paths.get(0);
Assert.assertEquals(3, path.size());
List<Set<String>> labels = path.labels();
Assert.assertEquals(3, labels.size());
Assert.assertEquals(1, labels.get(0).size());
Assert.assertTrue(labels.get(0).contains("a"));
Assert.assertEquals(1, labels.get(1).size());
Assert.assertTrue(labels.get(1).contains("sqlgPathFakeLabel"));
Assert.assertEquals(1, labels.get(2).size());
Assert.assertTrue(labels.get(2).contains("start"));
paths = this.sqlgGraph.traversal()
.V().hasLabel("A").as("a")
.out("ab").select("a").as("start")
.path().from("start").toList();
System.out.println(paths);
Assert.assertEquals(1, paths.size());
Assert.assertEquals(1, paths.get(0).size());
}
Seems its the limit(1)
that is confusing the labels.
@ktschmidt can you please test on your system if the issue is resolved. Thanks.
Trying to use path() in conjunction with start() to only look at the path from a specific point, and I'm seeing some strange results.
Specifically, I have an RHP vertex type and if I do a traversal out an edge from it then select back to where it started and do a path().start(), it doesn't seem to start the path at the point I ask.
Here is an example:
g.V().hasLabel("RHP").as("rhp").out("persona").select("rhp").limit(1).as("start").path().from("start")
I would expect this to have a path of just the RHP vertex as that is what was selected back to and set as "start", but what is returned includes the vertex on the other side of the "persona" edge:
[v[public.PI:::1],v[public.RHP:::14024]]
It also happens with an Org vertex type:
g.V().hasLabel("Org").as('org').out().select('org').limit(1).as('start').path().from('start')
I would expect the path to just have the Org, but I get the vertex resulting from the out():
[v[public.HCP:::3979],v[public.Org:::11]]
In another example, looking at the MutablePath object, the labels() method returns this:
[[start, pi], []]
Why are the two labels collected together in the first element of the array and nothing in the second element?