Graph Databases
Choose the route by travel time
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Choose ROUTE relationships and calculate accumulated costs using minutes. Inspect the per-destination results before selecting the requested target.
The fewest-hop shortcut loses to a longer route with lower accumulated minutes.
Inspect the component calculation
Calculate nonnegative path costs(
Typed weighted relationships: Choose a relationship type(
Relationships: Read graph relationships(
Graph: Directed weighted route graph
)
Relationship type: ROUTE
)
Starting ID: Start location
Cost field: minutes
)Examples and results
- Directed weighted route graph
Nodes and properties (4)
- A · Location
- B · Location
- C · Location
- D · Location
- A to B: ROUTE · minutes: 9
- A to C: ROUTE · minutes: 2
- C to B: ROUTE · minutes: 2
- B to D: ROUTE · minutes: 1
- C to D: ROUTE · minutes: 20
Inspect the node and relationship records
{ "nodes": [ { "id": "A", "kind": "Location" }, { "id": "B", "kind": "Location" }, { "id": "C", "kind": "Location" }, { "id": "D", "kind": "Location" } ], "edges": [ { "id": "ab", "source": "A", "target": "B", "type": "ROUTE", "minutes": 9 }, { "id": "ac", "source": "A", "target": "C", "type": "ROUTE", "minutes": 2 }, { "id": "cb", "source": "C", "target": "B", "type": "ROUTE", "minutes": 2 }, { "id": "bd", "source": "B", "target": "D", "type": "ROUTE", "minutes": 1 }, { "id": "cd", "source": "C", "target": "D", "type": "ROUTE", "minutes": 20 } ] }- Start location
A
- Required result
[ { "id": "A", "cost": 0 }, { "id": "B", "cost": 4 }, { "id": "C", "cost": 2 }, { "id": "D", "cost": 5 } ]
- Directed weighted route graph
Nodes and properties (4)
- A · Location
- B · Location
- C · Location
- D · Location
- A to B: ROUTE · minutes: 9
- A to C: ROUTE · minutes: 2
- C to B: ROUTE · minutes: 2
- B to D: ROUTE · minutes: 1
- C to D: ROUTE · minutes: 20
Inspect the node and relationship records
{ "nodes": [ { "id": "A", "kind": "Location" }, { "id": "B", "kind": "Location" }, { "id": "C", "kind": "Location" }, { "id": "D", "kind": "Location" } ], "edges": [ { "id": "ab", "source": "A", "target": "B", "type": "ROUTE", "minutes": 9 }, { "id": "ac", "source": "A", "target": "C", "type": "ROUTE", "minutes": 2 }, { "id": "cb", "source": "C", "target": "B", "type": "ROUTE", "minutes": 2 }, { "id": "bd", "source": "B", "target": "D", "type": "ROUTE", "minutes": 1 }, { "id": "cd", "source": "C", "target": "D", "type": "ROUTE", "minutes": 20 } ] }- Start location
A
- Required result
[ { "id": "A", "cost": 0 }, { "id": "B", "cost": 4 }, { "id": "C", "cost": 2 }, { "id": "D", "cost": 5 } ]
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
These components operate on the supplied records in your browser. They do not run a graph database or interpret Cypher. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.
A zero-cost transfer returns to the starting point
This check uses the pieces from “Read the destination without inventing reachability”.
BOTIE
- Directed weighted route graph
Nodes and properties (4)
- R · Location
- A · Location
- B · Location
- T · Location
- R to T: ROUTE · minutes: 8
- R to A: ROUTE · minutes: 0
- A to R: ROUTE · minutes: 0
- A to B: ROUTE · minutes: 2
- B to T: ROUTE · minutes: 1
- R to T: NEAR · minutes: 0
Inspect the node and relationship records
{ "nodes": [ { "id": "R", "kind": "Location" }, { "id": "A", "kind": "Location" }, { "id": "B", "kind": "Location" }, { "id": "T", "kind": "Location" } ], "edges": [ { "id": "direct", "source": "R", "target": "T", "type": "ROUTE", "minutes": 8 }, { "id": "transfer", "source": "R", "target": "A", "type": "ROUTE", "minutes": 0 }, { "id": "back", "source": "A", "target": "R", "type": "ROUTE", "minutes": 0 }, { "id": "ab", "source": "A", "target": "B", "type": "ROUTE", "minutes": 2 }, { "id": "bt", "source": "B", "target": "T", "type": "ROUTE", "minutes": 1 }, { "id": "near", "source": "R", "target": "T", "type": "NEAR", "minutes": 0 } ] }- Start location
R
- Destination
T
Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Why can the stale nine-minute B entry be skipped after a four-minute route has been recorded?
Separate the best known value from old queued candidates, and state the weight assumptions that justify settlement.
These components operate on the supplied records in your browser. They do not run a graph database or interpret Cypher.
Work through the Python challenges →