Skip to main content

Module logical_graph

Module logical_graph 

Source
Expand description

Logical graph containing the stops, etc. Unfinished.

The idea is, have a logical graph containing all the different blocks (plain, stops, etc.) separate from the physical track graph. Each track segment is a member of exactly one block. A segment can be a member of either any of the neighboring blocks, extending its border, or a completely new one. At the same time, block borders aren’t defined by signals. That means:

  • one can have a block without any signals covering it (like a station on open rail)
  • signals don’t create a block by themselves, allowing for the existence of “distant signals” (předvěsti)

Edges in the graph are directional in the logical sense. An edge exists for each physical connection that the blocks have. Each direction, however, can be “covered” by a different signal. That allows for the creation of (dopravny), where the situation can be something like this:

                 /-@-[track 3]-@-\
---[open rail]-x-/-@-[track 1]-@-\-x-[open rail]---

Where x denotes an entry signal and @ denote exit signals. In our current model, there is a total of 8 physical segments, whereas only four logical blocks, two for open rails on either side of the station and one block for each station track. Each open rail has two edges, connecting them to the station tracks. In the entry direction to the station tracks, the edge (or the crossing between blocks) is covered by the entry signals. Opposite direction is covered by the exit signals. Trains have a cache of nearing signals and respond to signals, not block changes. That means that even if the block borders are behind the entry signals, trains will still react in time to them.

The graph is a multigraph where each connection is identified by a tuple of (block, node). Thus, we can allow stops like this:

               /-[stop]-\
---[open rail]-/--------\-[open rail]---

In this situation, there’s only two logical blocks: one covering the open rail and another making up the stop. The open rail block needs to be connected to the stop from both sides and thus needs to have two connections to the same block.

Structs§

LogicalBlock
Each logical block stores an adjacency list of neigbouring blocks. It also stores the number of member segments to allow for cleanup when there aren’t any segments in the block.
LogicalConnection
LogicalConnectionKey
Since the graph of logical blocks is a multigraph, each connection is identified by a tuple of (block, node). Prioritizes nodes to allow fast queries of “What are all the connections at this node?”