removed bogus vertex and edges, cleaned up output a bit

[SVN r14604]
This commit is contained in:
Jeremy Siek 2002-07-25 18:52:00 +00:00
parent 149b84cb99
commit 42e13e2f11

View File

@ -24,8 +24,8 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <vector>
#include <iomanip> #include <iomanip>
#include <vector>
#include <boost/property_map.hpp> #include <boost/property_map.hpp>
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp> #include <boost/graph/graphviz.hpp>
@ -37,12 +37,11 @@ main()
using namespace boost; using namespace boost;
typedef adjacency_list<vecS, vecS, directedS, no_property, typedef adjacency_list<vecS, vecS, directedS, no_property,
property< edge_weight_t, int, property< edge_weight2_t, int > > > Graph; property< edge_weight_t, int, property< edge_weight2_t, int > > > Graph;
const int V = 6; const int V = 5;
typedef std::pair < int, int >Edge; typedef std::pair < int, int >Edge;
Edge edge_array[] = Edge edge_array[] =
{ Edge(0, 1), Edge(0, 2), Edge(0, 3), Edge(0, 4), Edge(0, 5), { Edge(0, 1), Edge(0, 4), Edge(0, 2), Edge(1, 3), Edge(1, 4),
Edge(1, 2), Edge(1, 5), Edge(1, 3), Edge(2, 4), Edge(2, 5), Edge(2, 1), Edge(3, 2), Edge(3, 0), Edge(4, 3)
Edge(3, 2), Edge(4, 3), Edge(4, 1), Edge(5, 4)
}; };
const std::size_t E = sizeof(edge_array) / sizeof(Edge); const std::size_t E = sizeof(edge_array) / sizeof(Edge);
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
@ -55,7 +54,7 @@ main()
#endif #endif
property_map < Graph, edge_weight_t >::type w = get(edge_weight, g); 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; int *wp = weights;
graph_traits < Graph >::edge_iterator e, e_end; graph_traits < Graph >::edge_iterator e, e_end;
@ -66,17 +65,17 @@ main()
int D[V][V]; int D[V][V];
johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0])); johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0]));
std::cout << " "; std::cout << " ";
for (int k = 0; k < V; ++k) for (int k = 0; k < V; ++k)
std::cout << k << " "; std::cout << std::setw(5) << k;
std::cout << std::endl; std::cout << std::endl;
for (int i = 0; i < V; ++i) { for (int i = 0; i < V; ++i) {
std::cout << i << " -> "; std::cout << i << " -> ";
for (int j = 0; j < V; ++j) { for (int j = 0; j < V; ++j) {
if (D[i][j] > 20 || D[i][j] < -20) if (D[i][j] > 20 || D[i][j] < -20)
std::cout << "inf "; std::cout << std::setw(5) << "inf";
else else
std::cout << D[i][j] << " "; std::cout << std::setw(5) << D[i][j];
} }
std::cout << std::endl; std::cout << std::endl;
} }