图数据库应用开发与高级数据建模技术
1. 实现路径查找方法
在社交网络用例中,我们要解决“人物 X 与人物 Y 是如何连接的”这一问题,下面将展示 findPathBetweenPeople() 方法的构建。
首先,回顾第 4 章中该遍历的结束状态:
g.V().has('person', 'first_name', 'Ted').
until(has('person', 'first_name', 'Denise')).
repeat(
both('friends').simplePath()
).path().next()
根据所学知识,将其转换为 Java 代码:
List<Path> friends = g.V().has("person", "first_name", fromName).
until(has("person", "first_name", toName)).
repeat(
both("friends").simplePath()
).path().toList();
此代码与之前的代码类似,但返回的是 Path 对象列表,而非更通用的 Object 类型。并且这里使用 both() 方法,而非在 getFriends() 和
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



