Modelling Supply Chains with Neo4j and Neodash

David Stevens
3 min readFeb 26, 2022

Part 1

Shortest path is one of the most widely known advantages of Graph technology and it a natural fit for supply chain modelling; continuing my learning track with different use cases and NeoDash, I thought I would try to create a simple Supply Chain application.

My starting model

Of course it’s possible to find many open datasets via a quick search to provie some real data; the challenge was finding a small enough working dataset so I could focus on shortest path and not load in 3000+ container ports. So starting with a list of the top 20 global ports, I quickly drew up a theoretical model to work from using Arrows.app .

The model quickly expanded into something a little more complex, with a total of 21 ports, detailing their name, country and their location (long & lat)

Data model within Arrows.app

By modelling (really it’s a drawing) in Arrows, I am able to very quickly import this data into my Neo4j instance, making minor changes as I reviewed the results and validate the routing logic I had defined.
I had some incorrect logic with routes going via New York to get from Antwerp to Hamburg :)

My ports— shown using NeoMap app

Building my supply chain application

With my data loaded, I can now begin creating my application using NeoDash,

The beauty of Neodash is the ease in which you can build results very quickly and especially take advantage of common parameter values being selected by the user and used across multiple visualisations.

Creating the parameters

Each route has a start and end location; so I just need to collect these with the “Parameter Select” widget within Neodash.

As I will use the same Node and Property values for both the source and destination, Neodash provides the means to extend the default parameter variable with a number suffix. So that my source parameter is $neodash_port_name_1 and my destination is $neodash_port_name_2

With these 2 parameters set, I can now build out the results (Note I set the final size of the widget to ‘little (4x1.5)’ , which is a nice update to keep the header section of a dashboard clean.

Calculating the shortest path

This couldn’t be easier, with a standard function already included within Cypher

match (p1:Port),(p2:Port),
p=shortestPath((p1)-[*..15]-(p2))
where p1.name= $neodash_port_name_1 AND p2.name=$neodash_port_name_2
return p

I can use the same query to create different views within the dashboard

Map visualisation of the shortest path from Shanghai to Antwerp
Graph visualisation of the shortest path from Shanghai to Antwerp
Table view of shortest path from Shanghai to Antwerp

Next steps…

Develop the shortest path query to consider the physical distance between the ports and not just the number of “hops”

--

--