我已经导入了一个图,并且可以确认顶点和边的数量与应该存在的数量相匹配。我在图上运行 simplepath() 计算,我的第一个问题是如何访问路径数组或映射返回的任何内容,我想我理解为我添加 .toList 并将其打印到控制台但是我只是得到 [] 一个空数组?
我在做什么错我需要访问从路径返回的结果集?
我在 Java 中而不是在 gramlin 控制台中运行的查询是:
g.V().has("id", "FirstVertexIdValue").shortestPath().with(ShortestPath.target, __.has("id", "EndVertexIdValue")).with(ShortestPath.distance, "weight").toList();
我还运行以下命令,但仍然返回一个空数组:
g.V("startVertexId").out().simplePath().until(hasId("endVertexId").path().limit(1);
systemOut 打印时的响应是 []
此外,graphml 文档示例在这里,它是一个非常大的文档,所以我只包含了 2 个顶点和 2 个边:
<?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>
尝试的查询示例:
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()