From 42e13e2f11aa3e8624c9f1833712d63c39057d3c Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Thu, 25 Jul 2002 18:52:00 +0000 Subject: [PATCH] removed bogus vertex and edges, cleaned up output a bit [SVN r14604] --- example/johnson-eg.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 301c65db..aae6fb96 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -37,12 +37,11 @@ main() using namespace boost; typedef adjacency_list > > Graph; - const int V = 6; + const int V = 5; typedef std::pair < int, int >Edge; Edge edge_array[] = - { Edge(0, 1), Edge(0, 2), Edge(0, 3), Edge(0, 4), Edge(0, 5), - Edge(1, 2), Edge(1, 5), Edge(1, 3), Edge(2, 4), Edge(2, 5), - Edge(3, 2), Edge(4, 3), Edge(4, 1), Edge(5, 4) + { Edge(0, 1), Edge(0, 4), Edge(0, 2), Edge(1, 3), Edge(1, 4), + Edge(2, 1), Edge(3, 2), Edge(3, 0), Edge(4, 3) }; const std::size_t E = sizeof(edge_array) / sizeof(Edge); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -55,7 +54,7 @@ main() #endif property_map < Graph, edge_weight_t >::type w = get(edge_weight, g); - int weights[] = { 0, 0, 0, 0, 0, 3, -4, 8, 1, 7, 4, -5, 2, 6 }; + int weights[] = { 3, -4, 8, 1, 7, 4, -5, 2, 6 }; int *wp = weights; graph_traits < Graph >::edge_iterator e, e_end; @@ -66,17 +65,17 @@ main() int D[V][V]; johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0])); - std::cout << " "; + std::cout << " "; for (int k = 0; k < V; ++k) - std::cout << k << " "; + std::cout << std::setw(5) << k; std::cout << std::endl; for (int i = 0; i < V; ++i) { - std::cout << i << " -> "; + std::cout << i << " -> "; for (int j = 0; j < V; ++j) { if (D[i][j] > 20 || D[i][j] < -20) - std::cout << "inf "; + std::cout << std::setw(5) << "inf"; else - std::cout << D[i][j] << " "; + std::cout << std::setw(5) << D[i][j]; } std::cout << std::endl; }