Search code examples
memgraphdb

Finding an alternate route using Cypher and Memgraph


I have a situation where I have several data centers spread across large distances. I have a main site and a backup site.

There are several routes between main and backup site. Based on conditions (connectivity issues) I need to decide which route to activate for data transfer.

I have all of the data on datacenters, routes and server characteristics stored as nodes and relationships in Memgraph.

How would a Cypher query look for a decision making scenario to chose to optimal route?


Solution

  • This issue can be solved using WSHORTEST algorithm. The code for this scenario could be something like this:

    MATCH p=(n:Node3 {prop:"c"})-[r *wShortest (e,v | 1) sum]->(t:Target), (n2:Node2 {prop:"b"})
    WHERE not n2 in nodes(p)
    RETURN p
    ORDER BY sum DESC;