Closed MartinBrugnara closed 4 years ago
I have actually drilled down the problem to the repeat()
step.
I have tried to replace the "x"
with the more standard .repeat(__.both().simplePath())
, but it produces the same exception.
The only way it works is by allowing cycles, tough this is not useful for BFS or shortest path...
--
Does anyone have a pattern to implement bfs and shortest path?
Hi, it is suppose to work. I have used the same query quite a few times. Can you post some sample data then I'll try reproduce your error.
Ok sorry only reading your error properly now. It seems more of a dependency version issue.
Can you try it just with plain java and not via some or other shell?
List<Path> vertices = this.sqlgGraph.traversal()
.V()
.hasLabel("Transmission")
.repeat(__.both("link").simplePath())
.until(
__.or(
__.has("type", P.within("HubSite", "ASwitch", "BSwitch")),
__.has("excluded", true),
__.loops().is(12)
)
)
.path()
.simplePath()
.toList();
This is a query that I have running on a production system.
Thanks @pietermartin for the quick response.
This is the dataset we are using for development: https://pastebin.com/3YpCcKz3 .
It is "thinker pop modern" with the addition of a property to all nodes, uid
, that act as a unique identifier over all nodes.
I am interacting directly from java. The "shell" you see in the stacktrace is just one of my packages. But I understand the confusion =)
I will try your solution and report back, thanks again!
I noticed I forgot to mention the version of thinkerpop I am using, here it is:
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>3.4.2</version>
</dependency>
I tested the following query as you suggested but it still raises the same exception (the query itself is god, I tested it against other systems).
List<Path> p = gts.V(source_id)
.repeat(__.both().simplePath())
.until(__.loops().is(depth))
.path()
.simplePath()
.toList();
I also tried:
V()
and adding an has
later to select the source node.both()
both()
.Sqlg already imports the TinkerPop
version it runs on. Sqlg 2.0.1
runs on TinkerPop 3.3.4
If want more up to date you can try Sqlg 2.0.2-SNAPSHOT
which runs on TinkerPop 3.4.1
This seams an interesting debug path;
I noticed there no tag yet for 2.0.2-SNAPSHOT
, nor artifact, and the commit mentioning it (258fcda338b051484a25acb4c96caa27dff069b8) still uses 3.3.4
.
Do you suggest to build from HEAD or do you have any particular commit in mind?
Thanks!
2.0.2-SNAPSHOT
is uploaded to maven snapshot repo.
It is the current master
branch.
https://github.com/pietermartin/sqlg/blob/master/pom.xml references 3.4.1
I am hoping to release it but alas work pressure is just not making me get there. There is one bug/change on postgresql 11 that still needs sorting.
For what its worth I am running on 2.0.2-SNAPSHOT
for quite some time in production already. So its quite stable.
I confirm this fixes the issue. So I guess it was a thinkerpop api compatibility issue.
Thanks for sqlg and the help @pietermartin !!
Nice, glad its working.
Hi all, I've got 1 error and 2 questions... Error
Questions 1) does sqlg support the
repeat().times().cap()
pattern? 2) if yes, why is the following exploding?Context
Version
Code
BFS Find the number of paths from
source_id
with up todepth
edges.Shortest path
Stack trace
https://pastebin.com/B0fuik4V