Example: 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 compare two methods of creating this network graph. One using a single complicated action, and another using 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.
Example action defining a one-way system
Method 2: Two Simpler Actions
Alternatively, you can add and connect all roads in one action then disconnect any roads not relevant to the one way system in a second action.
First action adds all roads
Second action removes roads not relevant to the one way system