One-way Road Network

In this example, we want to construct a network graph of one-way roads.

The direction is important when defining this network graph.

The end of a one-way street can touch either:

  • The start of another one-way street, or

  • Anywhere on a two-way street

A two-way street can touch either:

  • The start of a one-way street, or

  • Anywhere on a two-way street

Here we will show two methods of creating this network graph. One using a single complex Action, and another that uses two simple Actions.

Method 1: One Action

In our example below, a one-way road network is constructed using the built in operations add_position and connect_positions.

Although the network graph is constructed successfully, the required Action is very complicated.

One-way complex Action part 1.
The initial adding of the Roads root objects and the If logic to check if the road is one-way.
One-way complex Action part 2.
The Then logic will loop over the objects checking for one-way streets.
One-way complex Action part 3.
The Else will then find two-way streets.

Method 2: Two Simpler Actions

Alternatively, you can simplify the process by creating two separate Actions.

This first Action adds all roads to the network, including all two-way roads.

One-way simple Action 1 part 1.
One-way simple Action 1 part 2.

The second Action then removes all roads that aren't relevant to the one way system.

One-way simple Action 2 part 1.
One-way simple Action 2 part 2.

Using two Actions is simpler, but does mean that you will be processing all Roads twice.