Skip to content

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Angular Sub-Route Optimality

With distance (for example, in parsecs or meters), every part of a shortest route is itself a shortest route. With angular cost, this is not always true. The repository looks at routes found on the edge-based (pseudo-dual) graph, and at the cases that follow when Bellman's principle breaks: pairs of nodes where shortest routes take different ways, sorted into bubbles, superbubbles and chains. It also shows a way to compress the next table of the edge-based graph into something close to the usual node-to-node next table.

Six different ways between two junctions of a city street network, each taken by real shortest routes

▶ Video · 🗺 Interactive map

The idea

With distance, any part of a shortest route is itself a shortest route

The example is the Big Dipper constellation: seven stars, the lanes between them as roads, and the length of each lane as its cost. The shortest route from Alioth to Merak goes via Megrez and Phecda. Its part from Megrez to Merak is also the shortest route from Megrez to Merak.

This is Bellman's principle of optimality. Because of it, one small table is enough to rebuild every shortest route. For each star and each destination, the table holds only the next star. Following it step by step gives the whole route: from Alioth to Megrez, from Megrez to Phecda, from Phecda to Merak.

The Big Dipper: the shortest route from Alioth to Merak, its part from Megrez, and the next star on the way to Merak from every star

With angles, it breaks

In angular segment analysis, the cost of a route is the sum of its changes of direction (Hillier & Iida 2005; Turner 2007). It can also be combined with an edge weight, such as length:

cost = AngleWeight × Σ turn angles + LengthWeight × length

From Alioth to Merak, the route with the smallest total turn goes via Megrez and Dubhe. But from Megrez itself, it goes to Merak via Phecda. So the table cell "Megrez → Merak" needs two answers. The next step depends on the road segment by which the route arrived, and on its direction.

Sum of turns: from Alioth the simplest way to Merak goes via Dubhe, from Megrez via Phecda

One cell, two answers: the node alone is not enough to choose the next step

So the current node alone is not enough to choose the next step: the incoming directed segment is needed too. This question is discussed, for example, in work on route planning with turn costs (Caldwell 1961; Kirby & Potts 1969; Lim & Kim 2005; Geisberger & Vetter 2011).

The edge-based graph

In this graph, every directed segment of the street network becomes a node. Every turn from one segment into the next is a link, and its cost is the angle of the turn. Each street segment appears twice, once for each direction. This way a U-turn also counts as a turn.

Route planning calls this an edge-based or pseudo-dual graph (Geisberger & Vetter 2011). Space syntax often calls a representation with segments as nodes the dual representation, but it is not a dual graph in the strict mathematical sense (Winter 2002).

On this graph, with the directed segments as nodes, Bellman's principle works again. But this graph, with both directions of every segment, gives a much larger next table. Also, we want routes between nodes, not between segments. So ideally the next table of this graph should be stored more compactly and answer node-to-node queries. One way is to keep two tables. The first says which segment a route starts on, from each node. The second says which segment to take next, from any directed segment towards any node. This is a first-move table (Strasser, Botea & Harabor 2015), adapted to directed-segment states and node destinations.

The edge-based graph at Megrez: directed segments are the nodes, turns are the links and cost their angle

The compact table

The segment-to-node table is several times larger than a node-to-node table. But in most cells, the answer is the same whichever segment the route arrives by. So the approach proposed here keeps the usual node-to-node table. Only the cells where the incoming segment matters get an exception row, with one answer for each incoming segment.

The node-to-node table with one exception row

In a larger network: pairs with several ways, bubbles and chains

In a larger network, such as a city street network, many pairs of nodes behave like Megrez and Merak. Shortest routes pass through both nodes, but take different ways between them. The way depends on where the route starts and where it ends. Here such pairs are called variable pairs. A pair and its way back count as one.

The ways between two nodes form a few typical shapes. Their names are borrowed from genome assembly graphs (Zerbino & Birney 2008; Onodera, Sadakane & Shibuya 2013; Paten et al. 2018):

  • bubble: the ways meet only at the two ends;
  • superbubble: the ways touch inside, but no node is on all of them;
  • chain: several bubbles in a row, joined at nodes that every way passes.

Here these are loose, descriptive categories, not the formal definitions of those papers. There, a superbubble has more conditions, and a simple bubble is a superbubble too. Here each pair gets exactly one of the three kinds.

Bubble, superbubble and chain

A chain in the city street network: two ways that part and meet again; the yellow nodes join its bubbles

The more weight length has in the cost, the fewer such pairs there are. With length alone, the cost is a plain distance.

Usage

Command line. Requires the .NET 8 SDK.

dotnet run -c Release --project src/AngularSubRouteOptimality.Cli

The program builds the compact table and checks it against the full one. Then it lists the variable pairs with their kinds, the longest chains, and the ways of the first pair.

Library.

Network network = Network.ReadCsv("data/city-network.csv");            // one street segment per row: x1,y1,x2,y2
AngularPaths paths = AngularPaths.Compute(network, angleWeight: 1, lengthWeight: 0);

List<int> route = paths.Path(nodeStart, nodeDest);                    // the shortest route, as nodes
CompactNext compact = CompactNext.BuildGlobal(paths);                 // node-to-node table + exception rows
List<VariablePair> pairs = SubPaths.FindPairs(paths);                 // each with its kind and number of bubbles

How ties between routes of equal cost are broken: docs/tie-breaking.md.

Repository

src/AngularSubRouteOptimality the library: Network, AngularPaths, CompactNext, SubPaths
src/AngularSubRouteOptimality.Cli the console program
data/big-dipper.csv the seven stars of the Big Dipper, the example from the video
data/city-network.csv a city street network, cut to 2.5 km around its centre; derived from OpenStreetMap (ODbL)
docs/ the interactive map (GitHub Pages), the pictures, notes

References

  • Caldwell, T. (1961). On finding minimum routes in a network with turn penalties. Communications of the ACM 4(2).
  • Kirby, R. F., & Potts, R. B. (1969). The minimum route problem for networks with turn penalties and prohibitions. Transportation Research 3(3).
  • Winter, S. (2002). Modeling costs of turns in route planning. GeoInformatica 6(4), 345–361.
  • Hillier, B., & Iida, S. (2005). Network and psychological effects in urban movement. COSIT 2005, LNCS 3693.
  • Lim, Y., & Kim, H. (2005). A shortest path algorithm for real road network based on path overlap. Journal of the Eastern Asia Society for Transportation Studies 6, 1426–1438.
  • Turner, A. (2007). From axial to road-centre lines: a new representation for space syntax and a new model of route choice for transport network analysis. Environment and Planning B 34(3), 539–555.
  • Zerbino, D. R., & Birney, E. (2008). Velvet: algorithms for de novo short read assembly using de Bruijn graphs. Genome Research 18(5), 821–829.
  • Geisberger, R., & Vetter, C. (2011). Efficient routing in road networks with turn costs. SEA 2011, LNCS 6630, 100–111.
  • Onodera, T., Sadakane, K., & Shibuya, T. (2013). Detecting superbubbles in assembly graphs. WABI 2013, LNCS 8126.
  • Strasser, B., Botea, A., & Harabor, D. (2015). Compressing optimal paths with run length encoding. Journal of Artificial Intelligence Research 54, 593–629.
  • Paten, B., Eizenga, J. M., Rosen, Y. M., Novak, A. M., Garrison, E., & Hickey, G. (2018). Superbubbles, ultrabubbles, and cacti. Journal of Computational Biology 25(7), 649–663.

How to cite

fesmcr (2026). Angular Sub-Route Optimality. https://github.com/fesmcr/AngularSubRouteOptimality

@software{angular_subroute_optimality,
  author = {fesmcr},
  title  = {Angular Sub-Route Optimality},
  year   = {2026},
  url    = {https://github.com/fesmcr/AngularSubRouteOptimality}
}

License

The code is under the MIT License.

The street network (data/city-network.csv, docs/city-network.csv) and the maps are derived from OpenStreetMap: map data © OpenStreetMap contributors, available under the Open Database License (ODbL).

Releases

Packages

Contributors

Languages