I have imported a graph and can confirm that the number of vertex and edges matches the number that should be present. I run the simplepath() compute on the graph and my first question is how to access the path array or map whatever is returned, i think i understand as i add the .toList and print it to the console however i simply get [] an empty array?
What am i doing wrong i need to access the result set that comes back from the path?
my query which is run in Java not in the gramlin console is:
g.V().has("id", "FirstVertexIdValue").shortestPath().with(ShortestPath.target, __.has("id", "EndVertexIdValue")).with(ShortestPath.distance, "weight").toList();
I also run the following and still return an empty array:
g.V("startVertexId").out().simplePath().until(hasId("endVertexId").path().limit(1);
the response when systemOut printed is []
in addition the graphml doc sample is here, its a pretty big doc so i have just included 2 vertex and 2 edges:
<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns='http://graphml.graphdrawing.org/xmlns' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd'>
<key attr.name='weight' attr.type='double' for='edge' id='weight' />
<key attr.name='edgeid' attr.type='string' for='edge' id='edgeid' />
<key attr.name='alpha' attr.type='string' for='edge' id='alpha' />
<key attr.name='intendedpathlonlat' attr.type='string' for='edge' id='intendedpathlonlat' />
<key attr.name='levelid' attr.type='string' for='edge' id='levelid' />
<key attr.name='type' attr.type='string' for='edge' id='type' />
<key attr.name='relatedroutes' attr.type='string' for='node' id='relatedroutes' />
<key attr.name='description' attr.type='string' for='node' id='description' />
<key attr.name='title' attr.type='string' for='node' id='title' />
<key attr.name='on_finish_route' attr.type='string' for='node' id='on_finish_route' />
<key attr.name='on_starting_route' attr.type='string' for='node' id='on_starting_route' />
<key attr.name='level_id' attr.type='string' for='node' id='level_id' />
<key attr.name='waypoint_type' attr.type='string' for='node' id='waypoint_type' />
<key attr.name='name' attr.type='string' for='node' id='name' />
<key attr.name='lon' attr.type='string' for='node' id='lon' />
<key attr.name='lat' attr.type='string' for='node' id='lat' />
<graph edgedefault='directed' id='Station'>
<node id='L08-022'>
<data key='lat'>40.69330963</data>
<data key='lon'>-73.98752537</data>
<data key='name' />
<data key='waypoint_type'>escalator</data>
<data key='level_id'>1080000</data>
<data key='on_starting_route' />
<data key='on_finish_route' />
</node>
<node id='L08-023'>
<data key='lat'>40.69318355</data>
<data key='lon'>-73.98755793</data>
<data key='name' />
<data key='waypoint_type'>stairs</data>
<data key='level_id'>1080000</data>
<data key='on_starting_route' />
<data key='on_finish_route' />
</node>
<edge source='WL10-054' target='L10-029'>
<data key='type'>floor</data>
<data key='weight'>4.22</data>
<data key='levelid'>1100000</data>
<data key='intendedpathlonlat'></data>
<data key='alpha'>0.0</data>
<data key='edgeid'>RL10-059</data>
</edge>
<edge source='WL10-054' target='WL10-053'>
<data key='type'>floor</data>
<data key='weight'>5.69</data>
<data key='levelid'>1100000</data>
<data key='intendedpathlonlat'></data>
<data key='alpha'>0.0</data>
<data key='edgeid'>RL10-060</data>
</edge>
</graph>
</graphml>
A sample of the queries tried:
gremlin> g.V().has('T.id', 'L00-041').shortestPath().with(ShortestPath.target, __.has('T.id', 'L04-070')).with(ShortestPath.distance, 'weight').toList()
gremlin> g.V().has('T.id', 'L04-070').out().values('waypoint_type').fold()
==>[]
gremlin> g.V().has('T.id', 'L04-070').out().fold()
==>[]
gremlin> g.V().has('T.id', 'L04-070').out().values('lat').fold()
Without some sample data it's hard to tell what might be completely wrong but here's some things to consider based on the Gremlin in your question:
shortestPath()
-step is a an OLAP step and therefore requires that you define g
using withComputer()
- an example can be found here.T.id
when used in has()
). Perhaps that initial starting vertex isn't found properly? until()
condition) but does not specify a repeat()
operation.When my traversals don't return what I expect, I try to simplify them to the point where I can see where the traversal is filtering away the traversers that I expected. In other words, have Gremlin Console open and your graph connected. Ensure that g.V("startVertexId")
returns the vertex you expect. When satisfied of the result, add a step, run g.V("startVertexId").out()
and validate that. Continue with that pattern until you find out where your results are not returning. You can also run your traversal with profile()
step and it should show you where the traversers are filtering away, but sometimes it's easier to recognize by picking the traversal apart and simplifying.
I tested your traversal with the data you recently supplied in your question and when I make the adjustments as suggested in my answer and comments I don't seem to have a problem getting results:
gremlin> g.withComputer().V('WL10-054').shortestPath().with(ShortestPath.target, __.hasId('L10-029')).with(ShortestPath.distance, 'weight')
==>[v[WL10-054],v[L10-029]]