Commit Graph

10 Commits

Author SHA1 Message Date
Dan Kortschak
3d5d9d4a35 graph/path: allow incremental Bellman-Ford search
The impact on the current implementation is negligible.

name                          old time/op    new time/op    delta
BellmanFordFrom/500_tenth-8     4.14ms ± 1%    4.11ms ± 1%  -0.73%  (p=0.001 n=10+9)
BellmanFordFrom/1000_tenth-8    16.3ms ± 1%    16.1ms ± 1%  -0.82%  (p=0.000 n=10+10)
BellmanFordFrom/2000_tenth-8    66.2ms ± 1%    60.9ms ± 0%  -8.08%  (p=0.000 n=10+9)
BellmanFordFrom/500_half-8      18.0ms ± 5%    16.9ms ± 1%  -6.28%  (p=0.000 n=10+9)
BellmanFordFrom/1000_half-8     68.5ms ± 2%    67.4ms ± 1%  -1.50%  (p=0.000 n=9+8)
BellmanFordFrom/2000_half-8      281ms ± 1%     276ms ± 1%  -1.45%  (p=0.000 n=9+10)
BellmanFordFrom/500_full-8      33.4ms ± 0%    33.0ms ± 1%  -1.29%  (p=0.000 n=9+9)
BellmanFordFrom/1000_full-8      137ms ± 1%     133ms ± 0%  -3.11%  (p=0.000 n=8+9)
BellmanFordFrom/2000_full-8      549ms ± 1%     546ms ± 1%    ~     (p=0.065 n=10+9)

name                          old alloc/op   new alloc/op   delta
BellmanFordFrom/500_tenth-8      142kB ± 0%     142kB ± 0%    ~     (p=0.110 n=10+9)
BellmanFordFrom/1000_tenth-8     284kB ± 0%     284kB ± 0%    ~     (p=0.382 n=10+10)
BellmanFordFrom/2000_tenth-8     624kB ± 0%     624kB ± 0%    ~     (p=0.956 n=10+10)
BellmanFordFrom/500_half-8       142kB ± 0%     142kB ± 0%    ~     (p=0.666 n=10+10)
BellmanFordFrom/1000_half-8      284kB ± 0%     284kB ± 0%    ~     (p=0.070 n=10+8)
BellmanFordFrom/2000_half-8      624kB ± 0%     624kB ± 0%    ~     (p=0.290 n=10+10)
BellmanFordFrom/500_full-8       142kB ± 0%     142kB ± 0%    ~     (p=0.234 n=9+10)
BellmanFordFrom/1000_full-8      284kB ± 0%     284kB ± 0%    ~     (p=0.051 n=10+9)
BellmanFordFrom/2000_full-8      624kB ± 0%     624kB ± 0%    ~     (p=0.790 n=9+10)

name                          old allocs/op  new allocs/op  delta
BellmanFordFrom/500_tenth-8      2.03k ± 0%     2.03k ± 0%    ~     (all equal)
BellmanFordFrom/1000_tenth-8     4.03k ± 0%     4.03k ± 0%    ~     (all equal)
BellmanFordFrom/2000_tenth-8     8.03k ± 0%     8.03k ± 0%    ~     (all equal)
BellmanFordFrom/500_half-8       2.03k ± 0%     2.03k ± 0%    ~     (p=0.294 n=10+8)
BellmanFordFrom/1000_half-8      4.03k ± 0%     4.03k ± 0%    ~     (all equal)
BellmanFordFrom/2000_half-8      8.03k ± 0%     8.03k ± 0%    ~     (all equal)
BellmanFordFrom/500_full-8       2.03k ± 0%     2.03k ± 0%    ~     (p=1.000 n=10+10)
BellmanFordFrom/1000_full-8      4.03k ± 0%     4.03k ± 0%    ~     (all equal)
BellmanFordFrom/2000_full-8      8.03k ± 0%     8.03k ± 0%    ~     (p=1.000 n=10+10)

The performance of the lazy implementation is a little worse and allocations
are a lot worse than the eager implementation. This reflects that the benchmark
is performed on a graph with a single connected component which gains no benefit
from the incremental approach but suffers the cost of repeated reallocation for
appends.

name                          new time/op    inc time/op    delta
BellmanFordFrom/500_tenth-8     4.11ms ± 1%    4.28ms ± 1%   +4.05%  (p=0.000 n=9+10)
BellmanFordFrom/1000_tenth-8    16.1ms ± 1%    16.0ms ± 6%     ~     (p=0.143 n=10+10)
BellmanFordFrom/2000_tenth-8    60.9ms ± 0%    62.8ms ± 0%   +3.13%  (p=0.000 n=9+10)
BellmanFordFrom/500_half-8      16.9ms ± 1%    17.5ms ± 1%   +3.97%  (p=0.000 n=9+10)
BellmanFordFrom/1000_half-8     67.4ms ± 1%    70.0ms ± 2%   +3.76%  (p=0.000 n=8+9)
BellmanFordFrom/2000_half-8      276ms ± 1%     285ms ± 0%   +2.91%  (p=0.000 n=10+10)
BellmanFordFrom/500_full-8      33.0ms ± 1%    35.5ms ± 5%   +7.40%  (p=0.000 n=9+10)
BellmanFordFrom/1000_full-8      133ms ± 0%     137ms ± 2%   +3.48%  (p=0.000 n=9+9)
BellmanFordFrom/2000_full-8      546ms ± 1%     592ms ± 6%   +8.42%  (p=0.000 n=9+10)

name                          new alloc/op   inc alloc/op   delta
BellmanFordFrom/500_tenth-8      142kB ± 0%     182kB ± 0%  +27.84%  (p=0.000 n=9+10)
BellmanFordFrom/1000_tenth-8     284kB ± 0%     363kB ± 0%  +27.94%  (p=0.000 n=10+10)
BellmanFordFrom/2000_tenth-8     624kB ± 0%     893kB ± 0%  +43.26%  (p=0.000 n=10+10)
BellmanFordFrom/500_half-8       142kB ± 0%     182kB ± 0%  +27.83%  (p=0.000 n=10+10)
BellmanFordFrom/1000_half-8      284kB ± 0%     363kB ± 0%  +27.90%  (p=0.000 n=8+10)
BellmanFordFrom/2000_half-8      624kB ± 0%     893kB ± 0%  +43.25%  (p=0.000 n=10+10)
BellmanFordFrom/500_full-8       142kB ± 0%     182kB ± 0%  +27.82%  (p=0.000 n=10+10)
BellmanFordFrom/1000_full-8      284kB ± 0%     363kB ± 0%  +27.89%  (p=0.000 n=9+10)
BellmanFordFrom/2000_full-8      624kB ± 0%     893kB ± 0%  +43.23%  (p=0.000 n=10+10)

name                          new allocs/op  inc allocs/op  delta
BellmanFordFrom/500_tenth-8      2.03k ± 0%     2.10k ± 0%   +3.50%  (p=0.000 n=8+8)
BellmanFordFrom/1000_tenth-8     4.03k ± 0%     4.12k ± 0%   +2.39%  (p=0.000 n=10+10)
BellmanFordFrom/2000_tenth-8     8.03k ± 0%     8.17k ± 0%   +1.77%  (p=0.000 n=10+10)
BellmanFordFrom/500_half-8       2.03k ± 0%     2.10k ± 0%   +3.49%  (p=0.000 n=8+10)
BellmanFordFrom/1000_half-8      4.03k ± 0%     4.12k ± 0%   +2.36%  (p=0.000 n=9+10)
BellmanFordFrom/2000_half-8      8.03k ± 0%     8.17k ± 0%   +1.77%  (p=0.000 n=8+10)
BellmanFordFrom/500_full-8       2.03k ± 0%     2.10k ± 0%   +3.50%  (p=0.000 n=10+10)
BellmanFordFrom/1000_full-8      4.03k ± 0%     4.12k ± 0%   +2.36%  (p=0.000 n=9+10)
BellmanFordFrom/2000_full-8      8.03k ± 0%     8.17k ± 0%   +1.76%  (p=0.000 n=10+10)
2021-01-07 06:43:24 +10:30
Egon Elbre
63537531dd graph/path: generate benchmark data on-demand 2020-03-16 16:10:59 +02:00
Dan Kortschak
623f346311 graph: clean up lint 2019-11-02 05:20:20 +10:30
Dan Kortschak
0a637e253b graph/path: clean up AStar benchmarks with subtests 2019-09-07 07:05:52 +09:30
Dario Navin
88884a56e9 graph/path: use queue-based Bellman-Ford algorithm
See Sedgewick and Wayne, Algorithms 4th Edition from p672 onward.
2019-09-02 08:36:32 +09:30
kortschak
805531d142 all: change capitalization of gonum in license header 2017-11-02 06:54:08 +10:30
kortschak
7ba61f0ead graph/...: remove Weight method from Edge 2017-08-24 10:21:15 +09:30
kortschak
15ecc07d40 graph/path/...: update for int64 IDs 2017-07-02 08:38:42 +09:30
Brendan Tracey
d33397aa65 all: change import paths 2017-05-23 00:03:03 -06:00
Brendan Tracey
059a6c43f9 graph: imported graph as a subtree 2017-05-23 00:02:59 -06:00