From 69c98b39106cc2776f6a4983e548338ac24b5e84 Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Wed, 27 Nov 2024 15:36:04 +0100 Subject: simplify dijkstra --- test/graph/dijkstra.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/graph/dijkstra.cpp') diff --git a/test/graph/dijkstra.cpp b/test/graph/dijkstra.cpp index c0cfb7e..18420ac 100644 --- a/test/graph/dijkstra.cpp +++ b/test/graph/dijkstra.cpp @@ -13,21 +13,21 @@ void stress_test() { int n = Random::integer(2, 30); int m = Random::integer(n-1, max(n, min(500, n*(n-1) / 2 + 1))); - vector> adj(n); + vector>> adj(n); vector edges; Graph g(n); g.erdosRenyi(m); g.forEdges([&](int a, int b){ ll w = Random::integer(1, 1'000'000'000'000ll); - adj[a].push_back({w, b}); + adj[a].emplace_back(b, w); edges.push_back({a, b, w}); }); for (int i = 0; i < n; i++) { auto got = dijkstra(adj, i); auto expected = bellmannFord(n, edges, i); - + if (got != expected) cerr << "error" << FAIL; queries += n; } @@ -41,12 +41,12 @@ void performance_test() { timer t; Graph g(N); g.erdosRenyi(M); - vector> adj(N); + vector>> adj(N); g.forEdges([&](int a, int b){ ll w1 = Random::integer(1, 1'000'000'000'000ll); ll w2 = Random::integer(1, 1'000'000'000'000ll); - adj[a].push_back({w1, b}); - adj[b].push_back({w2, a}); + adj[a].emplace_back(b, w1); + adj[b].emplace_back(a, w2); }); t.start(); -- cgit v1.2.3