33 #include <boost/graph/fruchterman_reingold.hpp>
34 #include <boost/graph/circle_layout.hpp>
35 #include <boost/graph/random_layout.hpp>
36 #include <boost/graph/adjacency_list.hpp>
37 #include <boost/graph/topology.hpp>
38 #include <boost/lexical_cast.hpp>
39 #include <boost/random/linear_congruential.hpp>
43 typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS,
44 boost::property<boost::vertex_name_t, std::string> >
50 boost::property_map<Graph, boost::vertex_index_t>::type >
52 typedef boost::graph_traits<Graph>::vertex_descriptor
Vertex;
69 if (dataList.
count() < 3) {
78 foreach(
DataPtr data, dataList) {
82 qSort(xList.begin(), xList.end());
87 if (xList.last() - xList.first() < 10 && yList.
last() - yList.
first() < 10 ) {
88 qDebug() <<
"Aborting min cut alignment: nodes are already close to each other.";
98 foreach(
DataPtr data, dataList) {
99 node_mapping[data.get()] = counter++;
109 edges[counter++] =
Edge(node_mapping[p->from().get()], node_mapping[p->to().get()]);
119 PositionMap positionMap(position_vec.begin(),
get(boost::vertex_index, graph));
121 foreach(
DataPtr data, dataList) {
122 positionMap[counter][0] = data->x();
123 positionMap[counter][1] = data->y();
128 boost::fruchterman_reingold_force_directed_layout< topology_type, Graph, PositionMap >
132 boost::cooling(boost::linear_cooling<double>(100))
136 foreach(
DataPtr data, dataList) {
137 Vertex v = boost::vertex(node_mapping[data.get()], graph);
138 data->setX(positionMap[v][0]);
139 data->setY(positionMap[v][1]);
145 if (dataList.
length() == 0) {
155 foreach(
DataPtr data, dataList) {
162 radius = fmax(abs(xList.
first() - xList.
last()), abs(yList.
first() - yList.
last())) / 2;
169 foreach(
DataPtr data, dataList) {
170 node_mapping[data.get()] = counter++;
180 edges[counter++] =
Edge(node_mapping[p->from().get()], node_mapping[p->to().get()]);
190 PositionMap positionMap(position_vec.begin(),
get(boost::vertex_index, graph));
192 foreach(
DataPtr data, dataList) {
193 positionMap[counter][0] = data->x();
194 positionMap[counter][1] = data->y();
199 boost::circle_graph_layout< Graph, PositionMap >
206 foreach(
DataPtr data, dataList) {
207 Vertex v = boost::vertex(node_mapping[data.get()], graph);
208 data->setX(positionMap[v][0]);
209 data->setY(positionMap[v][1]);
217 kDebug() <<
"Temporary implementation, should be replaced soon.";
220 foreach(
int type, dataStructure->document()->dataTypeList()) {
221 allDataList << dataStructure->dataList(type);
231 kDebug() <<
"Temporary implementation, should be replaced soon.";
234 foreach(
int type, dataStructure->document()->dataTypeList()) {
235 allDataList << dataStructure->dataList(type);
boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::property< boost::vertex_name_t, std::string > > Graph
void undirectedGraphDefaultTopology(DataStructurePtr dataStructure)
applies a default topology for undirected graphs
QVector< point_type > PositionVec
boost::shared_ptr< DataStructure > DataStructurePtr
void applyCircleAlignment(DataList dataList, qreal radius=0)
applies Circle topology to data set
void directedGraphDefaultTopology(DataStructurePtr dataStructure)
applies a default topology for undirected graphs
boost::rectangle_topology topology_type
boost::shared_ptr< Pointer > PointerPtr
int count(const T &value) const
boost::graph_traits< Graph >::vertex_descriptor Vertex
topology_type::point_type point_type
boost::shared_ptr< Data > DataPtr
void applyMinCutTreeAlignment(DataList dataList)
applies Fruchterman-Reingold cut minimization
boost::iterator_property_map< PositionVec::iterator, boost::property_map< Graph, boost::vertex_index_t >::type > PositionMap