Ticket #4088: kamada_kawai_spring_layout error.txt

File kamada_kawai_spring_layout error.txt, 2.5 KB (added by Wolfgang Forstmeier <wolfgang.forstmeier@…>, 13 years ago)
Line 
1#include boostconfig.hpp
2#include boostgraphadjacency_list.hpp
3#include boostgraphgraph_utility.hpp
4#include boostgraphsimple_point.hpp
5#include boostproperty_mapproperty_map.hpp
6#include boostgraphcircle_layout.hpp
7#include boostgraphfruchterman_reingold.hpp
8#include boostgraphkamada_kawai_spring_layout.hpp
9#include iostream
10
11typedef boostsquare_topologypoint_difference_type Point;
12typedef boostsquare_topologypoint_type Point;
13
14struct VertexProperties
15{
16 stdsize_t index;
17 Point point;
18};
19
20struct EdgeProperty
21{
22 EdgeProperty(const stdsize_t &w)weight(w) {}
23 double weight;
24};
25
26
27typedef boostadjacency_listboostlistS,
28boostlistS, boostundirectedS,
29VertexProperties, EdgeProperty Graph;
30
31typedef boostproperty_mapGraph, stdsize_t VertexPropertiestype VertexIndexPropertyMap;
32typedef boostproperty_mapGraph, Point VertexPropertiestype PositionMap;
33typedef boostproperty_mapGraph, double EdgePropertytype WeightPropertyMap;
34
35typedef boostgraph_traitsGraphvertex_descriptor VirtexDescriptor;
36
37int main()
38{
39 Graph graph;
40
41 VertexIndexPropertyMap vertexIdPropertyMap = boostget(&VertexPropertiesindex, graph);
42
43 for (int i = 0; i 3; ++i) {
44 VirtexDescriptor vd = boostadd_vertex(graph);
45 vertexIdPropertyMap[vd] = i + 2;
46 }
47
48 boostadd_edge(boostvertex(1, graph), boostvertex(0, graph), EdgeProperty(5), graph);
49 boostadd_edge(boostvertex(2, graph), boostvertex(0, graph), EdgeProperty(5), graph);
50 boostadd_edge(boostvertex(3, graph), boostvertex(0, graph), EdgeProperty(5), graph);
51 boostadd_edge(boostvertex(4, graph), boostvertex(0, graph), EdgeProperty(5), graph);
52 boostadd_edge(boostvertex(5, graph), boostvertex(0, graph), EdgeProperty(5), graph);
53
54 stdcout Verticesn;
55 boostprint_vertices(graph, vertexIdPropertyMap);
56
57 stdcout Edgesn;
58 boostprint_edges(graph, vertexIdPropertyMap);
59
60 PositionMap positionMap = boostget(&VertexPropertiespoint, graph);
61 WeightPropertyMap weightPropertyMap = boostget(&EdgePropertyweight, graph);
62
63 boostcircle_graph_layout(graph, positionMap, 100);
64 boostfruchterman_reingold_force_directed_layout(graph, positionMap, boostsquare_topology());
65
66 boostkamada_kawai_spring_layout(graph, positionMap, weightPropertyMap,
67 boostsquare_topology(), boostside_lengthdouble(10), boostlayout_tolerance(),
68 1, vertexIdPropertyMap);
69
70 stdcout Coordinatesn;
71 boostgraph_traitsGraphvertex_iterator i, end;
72 for (boosttie(i, end) = boostvertices(graph); i != end; ++i) {
73 stdcout ID ( vertexIdPropertyMap[i] ) x positionMap[i][0] y positionMap[i][1] n;
74 }
75
76 return 0;
77}
78