Haseb Ansari
Haseb Ansari

Reputation: 607

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. Is there any query in ArangoDb for it. Please let me know if its possible. Thanks in advance.

Upvotes: 0

Views: 294

Answers (2)

Haseb Ansari
Haseb Ansari

Reputation: 607

{
"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

Upvotes: 0

dothebart
dothebart

Reputation: 6067

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 RETURNs with your actual query. 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.

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

Upvotes: 2

Related Questions