Showing
4 changed files
with
37 additions
and
35 deletions
... | @@ -123,36 +123,10 @@ void GraphItem::read_more() | ... | @@ -123,36 +123,10 @@ void GraphItem::read_more() |
123 | //모든 edge의 weight를 1로 설정 | 123 | //모든 edge의 weight를 1로 설정 |
124 | typename graph_traits<Graph>::edge_iterator ei, ei_end; | 124 | typename graph_traits<Graph>::edge_iterator ei, ei_end; |
125 | for (boost::tie(ei, ei_end)=boost::edges(*graph); ei!=ei_end; ++ei) { | 125 | for (boost::tie(ei, ei_end)=boost::edges(*graph); ei!=ei_end; ++ei) { |
126 | - boost::put(edge_weight, *graph, *ei, 1); | 126 | + boost::put(edge_weight, *graph, *ei, 1.0); |
127 | } | 127 | } |
128 | qDebug("* set edges weight end"); | 128 | qDebug("* set edges weight end"); |
129 | 129 | ||
130 | - | ||
131 | - //qDebug("* path highlighting start"); | ||
132 | - ////find start, end node's id | ||
133 | - //int start_idx, end_idx; | ||
134 | - //for (boost::tie(vi, vi_end)=vertices(*graph); vi!=vi_end; ++vi) { | ||
135 | - // string node_name = boost::get(vertex_name, *graph, *vi); | ||
136 | - // if (node_name == "Seong Chul Cho") { | ||
137 | - // start_idx = boost::get(vertex_index, *graph, *vi); | ||
138 | - // } else if (node_name == "Hyung Jin Kim") { | ||
139 | - // end_idx = boost::get(vertex_index, *graph, *vi); | ||
140 | - // } | ||
141 | - //} | ||
142 | - | ||
143 | - //typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor; | ||
144 | - //vector<vertex_descriptor> parents(num_vertices(*graph)); | ||
145 | - //vector<int> distances(num_vertices(*graph)); | ||
146 | - //vertex_descriptor start_vertex = vertex(start_idx, *graph); | ||
147 | - //dijkstra_shortest_paths(*graph, start_vertex, | ||
148 | - // predecessor_map(&parents[0]).distance_map(&distances[0])); | ||
149 | - ////path finding | ||
150 | - //vertex_descriptor current = boost::vertex(end_idx, *graph); | ||
151 | - //while (current != boost::vertex(start_idx, *graph)) { | ||
152 | - //} | ||
153 | - //qDebug("* path highlighting end"); | ||
154 | - | ||
155 | - | ||
156 | //graph layout calculation | 130 | //graph layout calculation |
157 | //using boost::random_graph_layout and boost::kamada_kawai_spring_layout | 131 | //using boost::random_graph_layout and boost::kamada_kawai_spring_layout |
158 | //vertex마다 계산된 좌표를 property에 적용 | 132 | //vertex마다 계산된 좌표를 property에 적용 |
... | @@ -395,6 +369,37 @@ void GraphItem::topK_highlight() | ... | @@ -395,6 +369,37 @@ void GraphItem::topK_highlight() |
395 | } | 369 | } |
396 | } | 370 | } |
397 | 371 | ||
372 | +void GraphItem::test() | ||
373 | +{ | ||
374 | + qDebug("* path highlighting start"); | ||
375 | + vertex_iterator vi, vi_end; | ||
376 | + //find start, end node's id | ||
377 | + int start_idx, end_idx; | ||
378 | + for (boost::tie(vi, vi_end)=vertices(*graph); vi!=vi_end; ++vi) { | ||
379 | + string node_name = boost::get(vertex_name, *graph, *vi); | ||
380 | + if (node_name == "Seong Chul Cho") { | ||
381 | + start_idx = boost::get(vertex_index, *graph, *vi); | ||
382 | + } else if (node_name == "Hyung Jin Kim") { | ||
383 | + end_idx = boost::get(vertex_index, *graph, *vi); | ||
384 | + } | ||
385 | + } | ||
386 | + | ||
387 | + vector<vertex_descriptor> parents(num_vertices(*graph)); | ||
388 | + vector<double> distances(num_vertices(*graph)); | ||
389 | + vertex_descriptor start_vertex = boost::vertex(start_idx, *graph); | ||
390 | + boost::dijkstra_shortest_paths(*graph, start_vertex, | ||
391 | + predecessor_map(boost::make_iterator_property_map(parents.begin(), boost::get(boost::vertex_index, *graph))). | ||
392 | + distance_map(boost::make_iterator_property_map(distances.begin(), get(boost::vertex_index, *graph)))); | ||
393 | + //path finding | ||
394 | + qDebug("* path finding start"); | ||
395 | + vertex_descriptor current = boost::vertex(end_idx, *graph); | ||
396 | + while (current != boost::vertex(start_idx, *graph)) { | ||
397 | + | ||
398 | + } | ||
399 | + qDebug("* path finding end"); | ||
400 | + qDebug("* path highlighting end"); | ||
401 | +} | ||
402 | + | ||
398 | //event handler | 403 | //event handler |
399 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | 404 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
400 | { | 405 | { | ... | ... |
... | @@ -30,6 +30,9 @@ public: | ... | @@ -30,6 +30,9 @@ public: |
30 | void reset_color(); | 30 | void reset_color(); |
31 | void topK_highlight(); | 31 | void topK_highlight(); |
32 | 32 | ||
33 | + //test | ||
34 | + void test(); | ||
35 | + | ||
33 | protected: | 36 | protected: |
34 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; | 37 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
35 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; | 38 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; | ... | ... |
... | @@ -74,6 +74,8 @@ void PaperGraphWidget::test() | ... | @@ -74,6 +74,8 @@ void PaperGraphWidget::test() |
74 | testCombo->addItem(to_string(rand() % 300).c_str()); | 74 | testCombo->addItem(to_string(rand() % 300).c_str()); |
75 | testCombo->addItem(to_string(rand() % 300).c_str()); | 75 | testCombo->addItem(to_string(rand() % 300).c_str()); |
76 | testCombo->addItem(to_string(rand() % 300).c_str()); | 76 | testCombo->addItem(to_string(rand() % 300).c_str()); |
77 | + | ||
78 | + graphItem->test(); | ||
77 | } | 79 | } |
78 | 80 | ||
79 | void PaperGraphWidget::handleSelectionChanged(int idx) | 81 | void PaperGraphWidget::handleSelectionChanged(int idx) | ... | ... |
... | @@ -92,14 +92,6 @@ typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor; | ... | @@ -92,14 +92,6 @@ typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor; |
92 | typedef square_topology<> Topology; | 92 | typedef square_topology<> Topology; |
93 | typedef typename Topology::point_type Point; | 93 | typedef typename Topology::point_type Point; |
94 | 94 | ||
95 | -/* structs */ | ||
96 | -//struct simple_edge { | ||
97 | -// int first, second; | ||
98 | -//}; | ||
99 | -//struct simple_edge { | ||
100 | -// int a, b; | ||
101 | -//}; | ||
102 | - | ||
103 | /* constants */ | 95 | /* constants */ |
104 | namespace { | 96 | namespace { |
105 | /* file io */ | 97 | /* file io */ | ... | ... |
-
Please register or login to post a comment