Graph Databases

Traverse the dependency cycle within a stated depth

BOTIE

Choose DEPENDS_ON edges and connect start and maximum depth to bounded reachability. Inspect the starting node at depth zero and the visited frontier.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

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.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Choose DEPENDS_ON edges and connect start and maximum depth to bounded reachability. Inspect the starting node at depth zero and the visited frontier.

Botie must stop revisiting equipment and keep the report’s reach explicit.

Inspect the component calculation
Find bounded reachable nodes(
  Typed relationships: Choose a relationship type(
    Relationships: Read graph relationships(
      Graph: Directed dependency graph
    )
    Relationship type: DEPENDS_ON
  )
  Starting ID: Starting asset
  Maximum depth: Maximum hop depth
)
Examples and results
Directed dependency graph
The nodes and directed relationships in this value.Records: P7; Asset. S1; Asset. S2; Asset. S3; Asset. Relationships: P7 to S1: DEPENDS_ON. S1 to S2: DEPENDS_ON. S2 to P7: DEPENDS_ON. S2 to S3: DEPENDS_ON. Full records and relationships are also listed below the diagram.P7 to S1: DEPENDS_ONDEPENDS_ONDEPENDS_ONS1 to S2: DEPENDS_ONDEPENDS_ONDEPENDS_ONS2 to P7: DEPENDS_ONDEPENDS_ONDEPENDS_ONS2 to S3: DEPENDS_ONDEPENDS_ONDEPENDS_ONP7P7AssetAssetS1S1AssetAssetS2S2AssetAssetS3S3AssetAsset
Nodes and properties (4)
  • P7 · Asset
  • S1 · Asset
  • S2 · Asset
  • S3 · Asset
  • P7 to S1: DEPENDS_ON
  • S1 to S2: DEPENDS_ON
  • S2 to P7: DEPENDS_ON
  • S2 to S3: DEPENDS_ON
Inspect the node and relationship records
{
  "nodes": [
    {
      "id": "P7",
      "kind": "Asset"
    },
    {
      "id": "S1",
      "kind": "Asset"
    },
    {
      "id": "S2",
      "kind": "Asset"
    },
    {
      "id": "S3",
      "kind": "Asset"
    }
  ],
  "edges": [
    {
      "id": "a",
      "source": "P7",
      "target": "S1",
      "type": "DEPENDS_ON"
    },
    {
      "id": "b",
      "source": "S1",
      "target": "S2",
      "type": "DEPENDS_ON"
    },
    {
      "id": "c",
      "source": "S2",
      "target": "P7",
      "type": "DEPENDS_ON"
    },
    {
      "id": "d",
      "source": "S2",
      "target": "S3",
      "type": "DEPENDS_ON"
    }
  ]
}
Starting asset
P7
Maximum hop depth
2
Required result
[
  {
    "id": "P7",
    "depth": 0
  },
  {
    "id": "S1",
    "depth": 1
  },
  {
    "id": "S2",
    "depth": 2
  }
]
Directed dependency graph
The nodes and directed relationships in this value.Records: P7; Asset. S1; Asset. S2; Asset. S3; Asset. Relationships: P7 to S1: DEPENDS_ON. S1 to S2: DEPENDS_ON. S2 to P7: DEPENDS_ON. S2 to S3: DEPENDS_ON. Full records and relationships are also listed below the diagram.P7 to S1: DEPENDS_ONDEPENDS_ONDEPENDS_ONS1 to S2: DEPENDS_ONDEPENDS_ONDEPENDS_ONS2 to P7: DEPENDS_ONDEPENDS_ONDEPENDS_ONS2 to S3: DEPENDS_ONDEPENDS_ONDEPENDS_ONP7P7AssetAssetS1S1AssetAssetS2S2AssetAssetS3S3AssetAsset
Nodes and properties (4)
  • P7 · Asset
  • S1 · Asset
  • S2 · Asset
  • S3 · Asset
  • P7 to S1: DEPENDS_ON
  • S1 to S2: DEPENDS_ON
  • S2 to P7: DEPENDS_ON
  • S2 to S3: DEPENDS_ON
Inspect the node and relationship records
{
  "nodes": [
    {
      "id": "P7",
      "kind": "Asset"
    },
    {
      "id": "S1",
      "kind": "Asset"
    },
    {
      "id": "S2",
      "kind": "Asset"
    },
    {
      "id": "S3",
      "kind": "Asset"
    }
  ],
  "edges": [
    {
      "id": "a",
      "source": "P7",
      "target": "S1",
      "type": "DEPENDS_ON"
    },
    {
      "id": "b",
      "source": "S1",
      "target": "S2",
      "type": "DEPENDS_ON"
    },
    {
      "id": "c",
      "source": "S2",
      "target": "P7",
      "type": "DEPENDS_ON"
    },
    {
      "id": "d",
      "source": "S2",
      "target": "S3",
      "type": "DEPENDS_ON"
    }
  ]
}
Starting asset
P7
Maximum hop depth
0
Required result
[
  {
    "id": "P7",
    "depth": 0
  }
]
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.

Two branches rejoin before a deeper cycle

This check uses the pieces from “Return the reached dependencies without the start”.

BOTIE

From R1, dependency branches reach S1 and S2, then rejoin at S3. S3 depends on S4, and S4 loops back to S1. A NEAR edge reaches S9. With a maximum of two dependency hops, predict the distinct reached IDs excluding R1.
Directed dependency graph
The nodes and directed relationships in this value.Records: R1; Asset. S1; Asset. S2; Asset. S3; Asset. S4; Asset. S9; Asset. Relationships: R1 to S1: DEPENDS_ON. R1 to S2: DEPENDS_ON. S1 to S3: DEPENDS_ON. S2 to S3: DEPENDS_ON. S3 to S4: DEPENDS_ON. S4 to S1: DEPENDS_ON. R1 to S9: NEAR. Full records and relationships are also listed below the diagram.R1 to S1: DEPENDS_ONDEPENDS_ONDEPENDS_ONR1 to S2: DEPENDS_ONDEPENDS_ONDEPENDS_ONS1 to S3: DEPENDS_ONDEPENDS_ONDEPENDS_ONS2 to S3: DEPENDS_ONDEPENDS_ONDEPENDS_ONS3 to S4: DEPENDS_ONDEPENDS_ONDEPENDS_ONS4 to S1: DEPENDS_ONDEPENDS_ONDEPENDS_ONR1 to S9: NEARNEARNEARR1R1AssetAssetS1S1AssetAssetS2S2AssetAssetS3S3AssetAssetS4S4AssetAssetS9S9AssetAsset
Nodes and properties (6)
  • R1 · Asset
  • S1 · Asset
  • S2 · Asset
  • S3 · Asset
  • S4 · Asset
  • S9 · Asset
  • R1 to S1: DEPENDS_ON
  • R1 to S2: DEPENDS_ON
  • S1 to S3: DEPENDS_ON
  • S2 to S3: DEPENDS_ON
  • S3 to S4: DEPENDS_ON
  • S4 to S1: DEPENDS_ON
  • R1 to S9: NEAR
Inspect the node and relationship records
{
  "nodes": [
    {
      "id": "R1",
      "kind": "Asset"
    },
    {
      "id": "S1",
      "kind": "Asset"
    },
    {
      "id": "S2",
      "kind": "Asset"
    },
    {
      "id": "S3",
      "kind": "Asset"
    },
    {
      "id": "S4",
      "kind": "Asset"
    },
    {
      "id": "S9",
      "kind": "Asset"
    }
  ],
  "edges": [
    {
      "id": "a",
      "source": "R1",
      "target": "S1",
      "type": "DEPENDS_ON"
    },
    {
      "id": "b",
      "source": "R1",
      "target": "S2",
      "type": "DEPENDS_ON"
    },
    {
      "id": "c",
      "source": "S1",
      "target": "S3",
      "type": "DEPENDS_ON"
    },
    {
      "id": "d",
      "source": "S2",
      "target": "S3",
      "type": "DEPENDS_ON"
    },
    {
      "id": "e",
      "source": "S3",
      "target": "S4",
      "type": "DEPENDS_ON"
    },
    {
      "id": "loop",
      "source": "S4",
      "target": "S1",
      "type": "DEPENDS_ON"
    },
    {
      "id": "near",
      "source": "R1",
      "target": "S9",
      "type": "NEAR"
    }
  ]
}
Starting asset
R1
Maximum hop depth
2

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.

Does excluding S3 at depth two establish that S3 is unreachable?

A bounded answer needs its boundary attached to the interpretation.

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 →
Continue the courseThe Route with Fewer Stops Takes Longer →