如何比较 ArangoDB 中的两个相似图,结果会产生路径和顶点的差异?
How to Compare Two Similar Graphs in ArangoDB that the result would yield the difference in Paths and Vertices?
我有两个图表,我想比较它们之间的差异。作为 AQL 查询的结果,我只想要它们之间路径和顶点的差异。 ArangoDb 中是否有任何查询。如果可能,请告诉我。提前致谢。
首先,您将在子查询中同时执行:
LET queryA = (RETURN {myFirstGraphResult: true, a: true, b: true})
LET queryB = (RETURN {mySecondGraphResult: true, a: true, b: true})
RETURN queryA == queryB
将前两个 RETURN
替换为您的实际查询。你需要确保它们的顺序相同,所以如果你有一个包含多个路径的数组,首先 SORT
它。
如果你想知道这两条路径的实际区别,
Jan has created a nice blogpost howto get the differences of two documnets in AQL
{
"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"
}
]
}
]
}
就像在这种情况下,它给了我错误的结果,尽管模式相同。
@dothebart
我有两个图表,我想比较它们之间的差异。作为 AQL 查询的结果,我只想要它们之间路径和顶点的差异。 ArangoDb 中是否有任何查询。如果可能,请告诉我。提前致谢。
首先,您将在子查询中同时执行:
LET queryA = (RETURN {myFirstGraphResult: true, a: true, b: true})
LET queryB = (RETURN {mySecondGraphResult: true, a: true, b: true})
RETURN queryA == queryB
将前两个 RETURN
替换为您的实际查询。你需要确保它们的顺序相同,所以如果你有一个包含多个路径的数组,首先 SORT
它。
如果你想知道这两条路径的实际区别, Jan has created a nice blogpost howto get the differences of two documnets in AQL
{
"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"
}
]
}
]
}
就像在这种情况下,它给了我错误的结果,尽管模式相同。
@dothebart