부스트 그래프 레이아웃 알고리즘을 사용하는 데 문제가 있습니다. 부스트 검증 1_41_0 mingw g ++ 4.4.0.부스트 1.41.0 그래프 레이아웃 알고리즘 사용 방법
그래서 내가 만난 문제가 있습니다. 나와 함께 나에게 제안 할 수 있습니까?
- fruchterman_reingold_force_directed_layout 함수는 컴파일되지 않습니다.
- kamada_kawai_spring_layout이 컴파일되었지만 프로그램이 중단되었습니다.
- 레이아웃 알고리즘에 대한 Boost 문서가 잘못되었으므로 fruchterman_reingold_force_directed_layout에 대한 샘플이 컴파일되지 않습니다.
이것은 나의 예입니다. 함수를 사용하려면 주석을 제거하십시오. 당신은 당신이 정점 ID 속성을 설치해야합니다 자신의 ID를 제공하기 위해 원하는 경우 (단지 그것을 그런 식으로 이름을 지정하여 ID로 vertexIdPropertyMap을 사용할 수 없습니다 63
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/simple_point.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/circle_layout.hpp>
#include <boost/graph/fruchterman_reingold.hpp>
#include <boost/graph/kamada_kawai_spring_layout.hpp>
#include <iostream>
//typedef boost::square_topology<>::point_difference_type Point;
typedef boost::square_topology<>::point_type Point;
struct VertexProperties
{
std::size_t index;
Point point;
};
struct EdgeProperty
{
EdgeProperty(const std::size_t &w):weight(w) {}
double weight;
};
typedef boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
VertexProperties, EdgeProperty > Graph;
typedef boost::property_map<Graph, std::size_t VertexProperties::*>::type VertexIndexPropertyMap;
typedef boost::property_map<Graph, Point VertexProperties::*>::type PositionMap;
typedef boost::property_map<Graph, double EdgeProperty::*>::type WeightPropertyMap;
typedef boost::graph_traits<Graph>::vertex_descriptor VirtexDescriptor;
int main()
{
Graph graph;
VertexIndexPropertyMap vertexIdPropertyMap = boost::get(&VertexProperties::index, graph);
for (int i = 0; i < 3; ++i) {
VirtexDescriptor vd = boost::add_vertex(graph);
vertexIdPropertyMap[vd] = i + 2;
}
boost::add_edge(boost::vertex(1, graph), boost::vertex(0, graph), EdgeProperty(5), graph);
boost::add_edge(boost::vertex(2, graph), boost::vertex(0, graph), EdgeProperty(5), graph);
std::cout << "Vertices\n";
boost::print_vertices(graph, vertexIdPropertyMap);
std::cout << "Edges\n";
boost::print_edges(graph, vertexIdPropertyMap);
PositionMap positionMap = boost::get(&VertexProperties::point, graph);
WeightPropertyMap weightPropertyMap = boost::get(&EdgeProperty::weight, graph);
boost::circle_graph_layout(graph, positionMap, 100);
// boost::fruchterman_reingold_force_directed_layout(graph, positionMap, boost::square_topology<>());
boost::kamada_kawai_spring_layout(graph, positionMap, weightPropertyMap,
boost::square_topology<>(), boost::side_length<double>(10), boost::layout_tolerance<>(),
1, vertexIdPropertyMap);
std::cout << "Coordinates\n";
boost::graph_traits<Graph>::vertex_iterator i, end;
for (boost::tie(i, end) = boost::vertices(graph); i != end; ++i) {
std::cout << "ID: (" << vertexIdPropertyMap[*i] << ") x: " << positionMap[*i][0] << " y: " << positionMap[*i][1] << "\n";
}
return 0;
}
답장을 보내 주셔서 감사합니다. 나는 단지 부스트 그래프 라이브러리를 연구 중이다. 부스트의 그래프 라이브러리 레이아웃 알고리즘을 사용하여 샘플을 제공해 줄 수 있습니까? 나는 부스트의 그래프 샘플과 문서가 오래되었다고 생각합니다. Daniil – Daniil
여기에서 시도하십시오. http://www.boost.org/doc/libs/1_42_0/libs/graph/test/layout_test.cpp – baol