简体   繁体   English

如何比较ArangoDB中的两个相似图,结果将产生路径和顶点差异?

[英]How to Compare Two Similar Graphs in ArangoDB that the result would yield the difference in Paths and Vertices?

I have two Graphs and I wanted to compare the difference between them. 我有两个图,我想比较它们之间的区别。 As a result from the AQL query I want only the difference in path and vertices between them. 作为AQL查询的结果,我只希望它们之间的路径和顶点有所不同。 Is there any query in ArangoDb for it. ArangoDb中是否有任何查询。 Please let me know if its possible. 请让我知道是否可能。 Thanks in advance. 提前致谢。

As first, you would execute both in a subquery: 首先,您将在子查询中执行这两个操作:

LET queryA = (RETURN {myFirstGraphResult: true, a: true, b: true})
LET queryB = (RETURN {mySecondGraphResult: true, a: true, b: true})
RETURN queryA == queryB

Replace the two first RETURN s with your actual query. 用您的实际查询替换前两个RETURN You need to make shure they're in the same sequence, so if you have an array in it with several paths, SORT it first. 您需要确保它们的顺序相同,因此,如果其中具有多个路径的数组,请先对其进行SORT

If you want to know the actual differences between the two paths, Jan has created a nice blogpost howto get the differences of two documnets in AQL 如果您想知道两条路径之间的实际差异, Jan创建了一个不错的博客文章,介绍了如何获取AQL中两个documnet的差异。

{
"graph1": [
  {
    "vertices": [
      {
        "task": "A",
        "_id": "ExampleCollection/A",
        "_rev": "184076271151",
        "_key": "A"
      },
      {
        "task": "B",
        "_id": "ExampleCollection/B",
        "_rev": "184078695983",
        "_key": "B"
      }
    ],
    "edges": [
      {
        "relation": "A to B",
        "_id": "ExampleEdges/184091213359",
        "_rev": "184247516719",
        "_key": "184091213359",
        "_from": "ExampleCollection/A",
        "_to": "ExampleCollection/B"
      }
    ]
  },
  {
    "vertices": [
      {
        "task": "A",
        "_id": "ExampleCollection/A",
        "_rev": "184076271151",
        "_key": "A"
      },
      {
        "task": "C",
        "_id": "ExampleCollection/C",
        "_rev": "184081120815",
        "_key": "C"
      }
    ],
    "edges": [
      {
        "relation": "A to C",
        "_id": "ExampleEdges/184250269231",
        "_rev": "184251711023",
        "_key": "184250269231",
        "_from": "ExampleCollection/A",
        "_to": "ExampleCollection/C"
      }
    ]
  }
],
"graph2": [
  {
    "vertices": [
      {
        "task": "A",
        "_id": "ExampleCollection/184258199087",
        "_rev": "184262917679",
        "_key": "184258199087"
      },
      {
        "task": "R",
        "_id": "ExampleCollection/R",
        "_rev": "184084397615",
        "_key": "R"
      }
    ],
    "edges": [
      {
        "relation": "A to R",
        "_id": "ExampleEdges/184265145903",
        "_rev": "184270781999",
        "_key": "184265145903",
        "_from": "ExampleCollection/184258199087",
        "_to": "ExampleCollection/R"
      }
    ]
  },
  {
    "vertices": [
      {
        "task": "A",
        "_id": "ExampleCollection/184258199087",
        "_rev": "184262917679",
        "_key": "184258199087"
      },
      {
        "task": "Q",
        "_id": "ExampleCollection/Q",
        "_rev": "184082365999",
        "_key": "Q"
      }
    ],
    "edges": [
      {
        "relation": "A to Q",
        "_id": "ExampleEdges/184264883759",
        "_rev": "184272420399",
        "_key": "184264883759",
        "_from": "ExampleCollection/184258199087",
        "_to": "ExampleCollection/Q"
      }
    ]
  }
]
}

Like in this case it gives me false result though the pattern is same. 像在这种情况下,尽管模式相同,但它给了我错误的结果。

@dothebart @dothebart

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

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