Я создаю график с помощью BGL и хотел бы объединить связанные свойства с vertex_index_t
, поскольку VertexProperty
графика - listS
.
Я использовал метод из Метод алгоритма BGL dijkstra_shortest_path не принимает внешнее свойство моей цветовой карты , однако я получаю specialization of template in different namespace
ошибку.
#include <boost/graph/adjacency_list.hpp>
namespace MyNameSpace {
using namespace boost;
struct VertexP {
std::string name;
unsigned int id;
};
typedef adjacency_list<vecS, listS, bidirectionalS, VertexP> Graph;
class VertexIndexMap {
public:
typedef boost::readable_property_map_tag category;
typedef size_t value_type;
typedef value_type reference;
typedef Graph::vertex_descriptor key_type;
VertexIndexMap(const Graph& g): _g(&g) {}
const Graph * _g;
};
template<>
struct property_map<Graph, vertex_index_t > {
typedef VertexIndexMap const_type;
};
}
Я попробовал следующий код, но не работает.
namespace MyNameSpace {
namespace boost {
template<>
struct property_map<Graph, vertex_index_t > {
typedef VertexIndexMap const_type;
};
}
}
Пожалуйста, помогите мне.
EDIT
Ниже мое текущее решение, не знаю, если оно правильное.
#include <boost/graph/adjacency_list.hpp>
namespace MyNameSpace {
using namespace boost;
struct VertexP {
std::string name;
unsigned int id;
};
typedef adjacency_list<vecS, listS, bidirectionalS, VertexP> Graph;
class VertexIndexMap {
public:
typedef boost::readable_property_map_tag category;
typedef size_t value_type;
typedef value_type reference;
typedef Graph::vertex_descriptor key_type;
VertexIndexMap(const Graph& g): _g(&g) {}
const Graph * _g;
};
}
namespace boost {
template<>
struct property_map<Graph, vertex_index_t > {
typedef VertexIndexMap const_type;
};
}
namespace MyNameSpace {
// the remaining code in namespace MyNameSpace
}