I'm attempting to find all unique paths from one friend to another.
When I use uniqueVertices: 'global', it is only returning one path because the end vertices is considered is part of the global unique.
FOR v,e,p
IN 1..6
ANY "entities/foo"
GRAPH "friendGraph"
OPTIONS {
bfs: true,
uniqueVertices: 'path'
}
SORT e.weight ASC
FILTER v._id == "entities/bar"
RETURN p
Is there a way to have uniqueVertices: 'global' ignore the end vertices? I know there isn't a way to specifically do that. But is there a way to accomplish the same thing?
'path' resulted in way to many results.
Thank you.
In order to use globally unique vertices but for the last one, you could add the last step in the path manually like so:
FOR v,e,p
IN 0..5
ANY "entities/foo"
GRAPH "friendGraph"
OPTIONS {
bfs: true,
uniqueVertices: 'global'
}
FILTER p.vertices[*]._id ALL != "entities/bar"
FOR w,f
IN 1..1
ANY v
GRAPH "friendGraph"
FILTER w._id == "entities/bar"
SORT f.weight ASC
RETURN { edges: APPEND(p.edges, [f]), vertices: APPEND(p.vertices, [w]) }
I'd like to note two things:
SORT operation you added might not achieve what you want: it sorts the paths by the weight of the path's last edgeuniqueVertices: 'path' would be correct, and there might well be a lot of them.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With