简体   繁体   English

给定一组强连接图的节点作为输入,我们可以获得它们之间的子图和路径遍历

[英]Given a set of nodes of a strongly connected graph as input can we get subgraph and path traversal between them

I have this requirement in ArangoDB AQL: I have a graph created with Document collection for node and Edge collection for directed edge relation.我在 ArangoDB AQL 中有这个要求:我有一个用节点的文档集合和有向边关系的边集合创建的图形。

I want to input a subset of list of nodes as input to AQL query and get all the node traversals /sub graph as the output.我想输入节点列表的子集作为 AQL 查询的输入,并获取所有节点遍历/子图作为输出。

How to achieve this from AQL?如何从 AQL 实现这一点? I want to know the relation between given nodes in that way.我想以这种方式知道给定节点之间的关系。 Please comment if more details are needed.如果需要更多详细信息,请发表评论。

I know below query now我现在知道下面的查询

FOR v IN 1..1 INBOUND[or OUTBOUND] 'Collection/_key' EdgeCollection
OPTIONS {bfs: true}
RETURN v

I'd recommend reviewing the queries on the ArangoDB sample page where it shows how it performs graph queries, and how to review the results.我建议查看ArangoDB 示例页面上的查询,其中显示了它如何执行图形查询以及如何查看结果。

In your sample query above you are only returning v (vertex information) as in FOR v IN .在上面的示例查询中,您只返回 v (顶点信息),如FOR v IN

That returns only the last vertex from every path that the query returns, it doesn't return edge or path information.这仅返回查询返回的每个路径的最后一个顶点,它不返回边或路径信息。

For that you need to test with FOR v, e, p IN and it will return extra information about the last edge (e), and the path (p) it took.为此,您需要使用FOR v, e, p IN进行测试,它将返回有关最后一条边 (e) 及其所采用的路径 (p) 的额外信息。

In particular look at the results of p as it contains a JSON object that holds path information, which is a collection of vertices and edges.特别是查看p的结果,因为它包含一个保存路径信息的 JSON 对象,它是顶点和边的集合。

By iterating through that data you should be able to extract the information you require.通过迭代这些数据,您应该能够提取所需的信息。

AQL gives you many tools to aggregate, group, filter, de-duplicate, and reduce data sets, so make sure you look at the wider language functions and practice building more complex queries. AQL 为您提供了许多工具来聚合、分组、过滤、去重和减少数据集,因此请确保您查看更广泛的语言功能并练习构建更复杂的查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM