Code

The measuring harness

The tests pass — all your functions are correct. Now we measure them.

Two files in this step, both complete. They are not your task.

wgraphbench.go — the measuring harness, with two new commands:

command what it does
algo route one route: BFS against Dijkstra, and the two queues
algo frontier the same over every destination — so the ratio is a claim, not an anecdote

They build the network with buildWeightedTrails — the generator from step 3.

main.go — two lines, as always: the route and frontier commands into usage and into the switch.

First run

$ algo gen -n 1000 -seed 3
$ algo route
$ algo frontier

route shows one pair: BFS against Dijkstra and the two queues. frontier sweeps every destination. You will read those numbers in the next steps.

Two things worth noticing at once:

  • frontier repeats the whole sweep several times (-rounds), because the clock varies from one sweep to the next; the work counter never does.
  • The two queues are always compared at the same cost — identical cost on N of N. If that ever reads fewer than N, one of your Dijkstra variants is wrong.