The State Machine
While not immediately obvious, the map of the city can be represented as a graph:
- Nodes represent the four land areas
- Edges represent the seven bridges connecting them
Note that we drew an undirected graph here. This is due to the fact that the bridges are bidirectional. We could also have drawn a directed graph with two edges for each bridge, but this would look more cluttered.
The same is true for the transition table. Instead of two rows for each bridge, we have one row for each bridge:
| State | Message | State | ||
|---|---|---|---|---|
| A | ⟵ | a | ⟶ | B |
| A | ⟵ | b | ⟶ | B |
| A | ⟵ | c | ⟶ | C |
| A | ⟵ | d | ⟶ | C |
| A | ⟵ | e | ⟶ | D |
| B | ⟵ | f | ⟶ | D |
| C | ⟵ | g | ⟶ | D |