10_dimacs9_routing

command
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 11 Imported by: 0

README

Example 10 — DIMACS 9 routing

What it demonstrates

Building a synthetic road-network graph with the DIMACS 9 benchmark harness, freezing it into an immutable CSR snapshot, and running a concrete single-source shortest-paths query (search.Dijkstra) over it. It reads back the shortest distance and reconstructs the route, then prints an environment-dependent latency summary from the harness.

Domain / scenario

A small synthetic road network generated by dimacs9.Synthetic. Every vertex points to its next-numbered neighbours with int64 edge weights derived deterministically from the endpoint indices, so the graph — and therefore every shortest path over it — is identical on every run. The fixed inputs (vertices = 12, edges = 30) yield a 12-node, 24-edge directed graph (average out-degree 2). The query is anchored at node 0 and routed to node 11; the shortest route is the multi-hop path 0 -> 1 -> 2 -> 3 -> 11 (hop weights 1 + 20 + 39 + 95 = 155), not a single direct edge.

How to run

go run ./examples/10_dimacs9_routing

Expected output

The graph size, path, and distance are deterministic. The latency lines (p50/p95/p99) are wall-clock measurements and vary from run to run and machine to machine — a representative run looks like:

Graph:  12 nodes, 24 edges
SSSP:   node 0 -> node 11
  distance: 155
  path:     0 -> 1 -> 2 -> 3 -> 11
Latency (environment-dependent, not a regression baseline):
  p50: 1.041µs
  p95: 1.5µs
  p99: 2.083µs

Key APIs

  • bench/dimacs9.Synthetic — generate the deterministic synthetic road-network adjacency list.
  • bench/dimacs9.Run / bench/dimacs9.Report.Percentile — run the query workload and read back latency percentiles.
  • graph/csr.BuildFromAdjList — freeze the builder into an immutable CSR snapshot; CSR.Order / CSR.Size report the node and edge counts.
  • graph/adjlist.AdjList.Mapper — translate between node values and compact NodeIDs (Lookup, Resolve).
  • search.Dijkstra — single-source shortest paths over non-negative weights.
  • search.Distances.Distance / search.Distances.Path — read back the cost and reconstruct the route.

Further reading

Documentation

Overview

Example 10_dimacs9_routing — build a small synthetic road-network graph with the DIMACS 9 harness, run a concrete single-source shortest-paths query over it, and print an environment-dependent latency summary from the harness for flavour.

The structural output — node count, edge count, the shortest path and its distance — is deterministic for the inputs hard-coded below and serves as the regression baseline a future change should preserve. The trailing latency lines (p50/p95/p99) are timing measurements and vary from run to run and machine to machine; they are clearly separated and are not part of the regression baseline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL