Witajcie!
Skompilowałem bibliotekę Boost z VC++ 2005 ale algorytm w dalszym ciągu nie działa.
Nie mam już siły z tym walczyć :(
oto program i logi:
#include <boost/config.hpp>
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/johnson_all_pairs_shortest.hpp>
int
main()
{
using namespace boost;
typedef adjacency_list<vecS, vecS, directedS, no_property,
property< edge_weight_t, int, property< edge_weight2_t, int > > > Graph;
const int V = 6;
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)
};
const std::size_t E = sizeof(edge_array) / sizeof(Edge);
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
// VC++ can't handle the iterator constructor
Graph g(V);
for (std::size_t j = 0; j < E; ++j)
add_edge(edge_array[j].first, edge_array[j].second, g);
#else
Graph g(edge_array, edge_array + E, V);
#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 *wp = weights;
graph_traits < Graph >::edge_iterator e, e_end;
for (boost::tie(e, e_end) = edges(g); e != e_end; ++e)
w[*e] = *wp++;
std::vector < int >d(V, (std::numeric_limits < int >::max)());
int D[V][V];
johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0]));
std::cout << " ";
for (int k = 0; k < V; ++k)
std::cout << std::setw(5) << k;
std::cout << std::endl;
for (int i = 0; i < V; ++i) {
std::cout << std::setw(3) << i << " -> ";
for (int j = 0; j < V; ++j) {
if (D[i][j] == (std::numeric_limits<int>::max)())
std::cout << std::setw(5) << "inf";
else
std::cout << std::setw(5) << D[i][j];
}
std::cout << std::endl;
}
std::ofstream fout("figs/johnson-eg.dot");
fout << "digraph A {\n"
<< " rankdir=LR\n"
<< "size=\"5,3\"\n"
<< "ratio=\"fill\"\n"
<< "edge[style=\"bold\"]\n" << "node[shape=\"circle\"]\n";
graph_traits < Graph >::edge_iterator ei, ei_end;
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
fout << source(*ei, g) << " -> " << target(*ei, g)
<< "[label=" << get(edge_weight, g)[*ei] << "]\n";
fout << "}\n";
return 0;
}
LOG:
1>------ Build started: Project: program, Configuration: Debug Win32 ------
1>Compiling...
1>program.cpp
1>C:\Program Files\boost\boost_1_42\boost/property_map/shared_array_property_map.hpp(36) : error C2666: 'boost::shared_array<T>::operator []' : 2 overloads have similar conversions
1> with
1> [
1> T=DT
1> ]
1> C:\Program Files\boost\boost_1_42\boost/smart_ptr/shared_array.hpp(85): could be 'DT &boost::shared_array<T>::operator [](ptrdiff_t) const'
1> with
1> [
1> T=DT
1> ]
1> or 'built-in C++ operator[(void (__cdecl *)(boost::shared_array<T> ***), unsigned int)'
1> with
1> [
1> T=DT
1> ]
1> while trying to match the argument list '(const boost::shared_array<T>, unsigned int)'
1> with
1> [
1> T=DT
1> ]
1> C:\Program Files\boost\boost_1_42\boost/property_map/shared_array_property_map.hpp(35) : while compiling class template member function 'DT &boost::shared_array_property_map<T,IndexMap>::operator [](unsigned int) const'
1> with
1> [
1> T=DT,
1> IndexMap=VertexID2
1> ]
1> C:\Program Files\boost\boost_1_42\boost/graph/johnson_all_pairs_shortest.hpp(98) : see reference to class template instantiation 'boost::shared_array_property_map<T,IndexMap>' being compiled
1> with
1> [
1> T=DT,
1> IndexMap=VertexID2
1> ]
1> C:\Program Files\boost\boost_1_42\boost/graph/johnson_all_pairs_shortest.hpp(170) : see reference to function template instantiation 'bool boost::johnson_all_pairs_shortest_paths<VertexAndEdgeListGraph,int[6][6],VertexID,Weight,std::less<_Ty>,boost::closed_plus<T>,int,int>(VertexAndEdgeListGraph &,DistanceMatrix (&),VertexID,Weight,const BinaryPredicate &,const BinaryFunction &,const Infinity &,DistanceZero)' being compiled
1> with
1> [
1> VertexAndEdgeListGraph=Graph,
1> VertexID=boost::vec_adj_list_vertex_id_map<boost::no_property,unsigned int>,
1> Weight=boost::adj_list_edge_property_map<boost::directed_tag,int,const int &,unsigned int,const boost::property<boost::edge_weight_t,int,boost::property<boost::edge_weight2_t,int>>,boost::edge_weight_t>,
1> _Ty=WT,
1> T=WT,
1> DistanceMatrix=int [6][6],
1> BinaryPredicate=std::less<WT>,
1> BinaryFunction=boost::closed_plus<WT>,
1> Infinity=int,
1> DistanceZero=int
1> ]
1> C:\Program Files\boost\boost_1_42\boost/graph/johnson_all_pairs_shortest.hpp(187) : see reference to function template instantiation 'bool boost::detail::johnson_dispatch<VertexAndEdgeListGraph,int[6][6],int*,boost::vertex_distance_t,boost::no_property,boost::adj_list_edge_property_map<Directed,Value,Ref,Vertex,Property,Tag>,boost::vec_adj_list_vertex_id_map<boost::no_property,Vertex>>(VertexAndEdgeListGraph &,DistanceMatrix (&),const boost::bgl_named_params<T,boost::vertex_distance_t,Base> &,Weight,VertexID)' being compiled
1> with
1> [
1> VertexAndEdgeListGraph=Graph,
1> Directed=boost::directed_tag,
1> Value=int,
1> Ref=const int &,
1> Vertex=unsigned int,
1> Property=const boost::property<boost::edge_weight_t,int,boost::property<boost::edge_weight2_t,int>>,
1> Tag=boost::edge_weight_t,
1> DistanceMatrix=int [6][6],
1> T=int *,
1> Base=boost::no_property,
1> Weight=boost::adj_list_edge_property_map<boost::directed_tag,int,const int &,unsigned int,const boost::property<boost::edge_weight_t,int,boost::property<boost::edge_weight2_t,int>>,boost::edge_weight_t>,
1> VertexID=boost::vec_adj_list_vertex_id_map<boost::no_property,unsigned int>
1> ]
1> c:\documents and settings\pawlik\moje dokumenty\visual studio 2005\projects\program\program\program.h(44) : see reference to function template instantiation 'bool boost::johnson_all_pairs_shortest_paths<Graph,int[6][6],int*,boost::vertex_distance_t,boost::no_property>(VertexAndEdgeListGraph &,DistanceMatrix (&),const boost::bgl_named_params<T,Tag,Base> &)' being compiled
1> with
1> [
1> VertexAndEdgeListGraph=Graph,
1> DistanceMatrix=int [6][6],
1> T=int *,
1> Tag=boost::vertex_distance_t,
1> Base=boost::no_property
1> ]
1>Build log was saved at "file://c:\Documents and Settings\pawlik\Moje dokumenty\Visual Studio 2005\Projects\program\program\Debug\BuildLog.htm"
1>program - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========