Showing
2 changed files
with
25 additions
and
43 deletions
... | @@ -15,10 +15,8 @@ using namespace boost; | ... | @@ -15,10 +15,8 @@ using namespace boost; |
15 | 15 | ||
16 | 16 | ||
17 | enum vertex_position_t { vertex_position }; | 17 | enum vertex_position_t { vertex_position }; |
18 | -//enum vertex_type_t { vertex_type }; | ||
19 | namespace boost { | 18 | namespace boost { |
20 | BOOST_INSTALL_PROPERTY(vertex, position); | 19 | BOOST_INSTALL_PROPERTY(vertex, position); |
21 | - //BOOST_INSTALL_PROPERTY(vertex, type); | ||
22 | } | 20 | } |
23 | typedef square_topology<>::point_type point; | 21 | typedef square_topology<>::point_type point; |
24 | struct simple_edge { | 22 | struct simple_edge { | ... | ... |
... | @@ -34,7 +34,7 @@ const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; | ... | @@ -34,7 +34,7 @@ const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; |
34 | const int SCREEN_SIZE = 500; | 34 | const int SCREEN_SIZE = 500; |
35 | const int NODE_LIMIT = 100; | 35 | const int NODE_LIMIT = 100; |
36 | 36 | ||
37 | -Graph read_graph(ifstream& in) { | 37 | +Graph read_graph(ifstream& in) throw(std::exception) { |
38 | /** | 38 | /** |
39 | * Parse Paper dataset | 39 | * Parse Paper dataset |
40 | * - paper_key, [author_list], publish_year | 40 | * - paper_key, [author_list], publish_year |
... | @@ -47,6 +47,7 @@ Graph read_graph(ifstream& in) { | ... | @@ -47,6 +47,7 @@ Graph read_graph(ifstream& in) { |
47 | vector<pair<string, string>> edges; | 47 | vector<pair<string, string>> edges; |
48 | 48 | ||
49 | //String <--> int 양방향 변환을 위해 bidirectional map 상숑 | 49 | //String <--> int 양방향 변환을 위해 bidirectional map 상숑 |
50 | + //map<string, int> -> <vertex label, vertex index> | ||
50 | typedef boost::bimap<string, int> bm_type; | 51 | typedef boost::bimap<string, int> bm_type; |
51 | bm_type node_ids; | 52 | bm_type node_ids; |
52 | vector<simple_edge> edges_indexes; //int로 변환된 edge | 53 | vector<simple_edge> edges_indexes; //int로 변환된 edge |
... | @@ -115,32 +116,27 @@ Graph read_graph(ifstream& in) { | ... | @@ -115,32 +116,27 @@ Graph read_graph(ifstream& in) { |
115 | 116 | ||
116 | 117 | ||
117 | //모든 edge weight 1로 만들기 | 118 | //모든 edge weight 1로 만들기 |
118 | - edge_iterator ei, ei_end; | 119 | + //edge_iterator ei, ei_end; |
119 | - for (boost::tie(ei, ei_end)=boost::edges(graph); ei!=ei_end; ++ei) { | 120 | + //for (boost::tie(ei, ei_end)=boost::edges(graph); ei!=ei_end; ++ei) { |
120 | - boost::put(edge_weight, graph, *ei, 1); | 121 | + // boost::put(edge_weight, graph, *ei, 1); |
121 | - } | 122 | + //} |
122 | - | 123 | + ////path finding between two vertices |
123 | - | 124 | + ////using dijkstra algorithm |
124 | - //path finding between two vertices | 125 | + ////ex) "Werner Keim" ---> "Arpad L. Scholtz" (in dataset 2nd line) |
125 | - //using dijkstra algorithm | 126 | + //qDebug() << "* path finding start"; |
126 | - //ex) "Werner Keim" ---> "Arpad L. Scholtz" (in dataset 2nd line) | 127 | + //typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor; |
127 | - qDebug() << "* path finding start"; | 128 | + //std::vector<vertex_descriptor> parent(num_vertices(graph)); |
128 | - typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor; | 129 | + //std::vector<int> distance(num_vertices(graph)); |
129 | - std::vector<vertex_descriptor> parent(num_vertices(graph)); | 130 | + //int start_idx = node_ids.left.find("Werner Keim")->get_right(); |
130 | - std::vector<int> distance(num_vertices(graph)); | 131 | + //vertex_descriptor start_v = vertex(start_idx, graph); |
131 | - int start_idx = node_ids.left.find("Werner Keim")->get_right(); | 132 | + //dijkstra_shortest_paths( |
132 | - vertex_descriptor start_v = vertex(start_idx, graph); | 133 | + // graph, |
133 | - | 134 | + // start_v, |
134 | - dijkstra_shortest_paths( | 135 | + // predecessor_map( |
135 | - graph, | 136 | + // boost::make_iterator_property_map(parent.begin(), get(boost::vertex_index, graph)) |
136 | - start_v, | 137 | + // ).distance_map(boost::make_iterator_property_map(distance.begin(), get(boost::vertex_index, graph))) |
137 | - predecessor_map( | 138 | + //); |
138 | - boost::make_iterator_property_map(parent.begin(), get(boost::vertex_index, graph)) | 139 | + //qDebug() << "* path finding end"; |
139 | - ).distance_map(boost::make_iterator_property_map(distance.begin(), get(boost::vertex_index, graph))) | ||
140 | - ); | ||
141 | - qDebug() << "* path finding end"; | ||
142 | - | ||
143 | - int aaaa = 3; | ||
144 | 140 | ||
145 | 141 | ||
146 | //graph layout calculation | 142 | //graph layout calculation |
... | @@ -159,7 +155,6 @@ Graph read_graph(ifstream& in) { | ... | @@ -159,7 +155,6 @@ Graph read_graph(ifstream& in) { |
159 | rectangle_topology<> rect_top(gen, | 155 | rectangle_topology<> rect_top(gen, |
160 | -SCREEN_SIZE/2, -SCREEN_SIZE/2, | 156 | -SCREEN_SIZE/2, -SCREEN_SIZE/2, |
161 | SCREEN_SIZE/2, SCREEN_SIZE/2); | 157 | SCREEN_SIZE/2, SCREEN_SIZE/2); |
162 | - std::vector<Topology::point_difference_type> displacements(num_vertices(graph)); | ||
163 | 158 | ||
164 | switch (LAYOUT_MODE) { | 159 | switch (LAYOUT_MODE) { |
165 | case GRAPH_LAYOUT::RANDOM_LAYOUT: | 160 | case GRAPH_LAYOUT::RANDOM_LAYOUT: |
... | @@ -180,17 +175,6 @@ Graph read_graph(ifstream& in) { | ... | @@ -180,17 +175,6 @@ Graph read_graph(ifstream& in) { |
180 | // break; | 175 | // break; |
181 | 176 | ||
182 | case GRAPH_LAYOUT::FRUCHTERMAN_REINGOLD_LAYOUT: | 177 | case GRAPH_LAYOUT::FRUCHTERMAN_REINGOLD_LAYOUT: |
183 | - //fruchterman_reingold_force_directed_layout(graph, | ||
184 | - // get(vertex_position, graph), | ||
185 | - // topology, | ||
186 | - // square_distance_attractive_force(), | ||
187 | - // square_distance_repulsive_force(), | ||
188 | - // all_force_pairs(), | ||
189 | - // linear_cooling<double>(SCREEN_SIZE/2), | ||
190 | - // make_iterator_property_map(displacements.begin(), | ||
191 | - // get(vertex_index, graph), | ||
192 | - // Topology::point_difference_type()) | ||
193 | - //); | ||
194 | fruchterman_reingold_force_directed_layout(graph, | 178 | fruchterman_reingold_force_directed_layout(graph, |
195 | get(vertex_position, graph), | 179 | get(vertex_position, graph), |
196 | topology, | 180 | topology, |
... | @@ -216,8 +200,8 @@ int main(int argc, char *argv[]) | ... | @@ -216,8 +200,8 @@ int main(int argc, char *argv[]) |
216 | w.print_graph(read_graph(fin)); | 200 | w.print_graph(read_graph(fin)); |
217 | fin.close(); | 201 | fin.close(); |
218 | } catch (const std::exception& e) { | 202 | } catch (const std::exception& e) { |
219 | - qDebug() << "Error: " << e.what() << endl; | 203 | + qDebug() << "Error: " << e.what(); |
220 | - return -1; | 204 | + return EXIT_FAILURE; |
221 | } | 205 | } |
222 | 206 | ||
223 | 207 | ... | ... |
-
Please register or login to post a comment