Showing
4 changed files
with
52 additions
and
24 deletions
| ... | @@ -78,10 +78,19 @@ GraphItem::GraphItem(ifstream& fin) | ... | @@ -78,10 +78,19 @@ GraphItem::GraphItem(ifstream& fin) |
| 78 | //index: 0 ~ ... | 78 | //index: 0 ~ ... |
| 79 | //name : map의 value(i) 기준으로 찾은 Key | 79 | //name : map의 value(i) 기준으로 찾은 Key |
| 80 | // map --> map<string, int> (boost bidirectional map) | 80 | // map --> map<string, int> (boost bidirectional map) |
| 81 | + std::string node_label = node_ids.right.find(i)->get_left(); | ||
| 81 | boost::put(vertex_index, *graph, *vi, i); | 82 | boost::put(vertex_index, *graph, *vi, i); |
| 82 | - boost::put(vertex_name, *graph, *vi, | 83 | + boost::put(vertex_name, *graph, *vi, node_label); |
| 83 | - node_ids.right.find(i)->get_left()); | 84 | + |
| 84 | - | 85 | + //node type 설정 |
| 86 | + if (boost::regex_match(node_label, paper_reg)) { | ||
| 87 | + //Paper | ||
| 88 | + boost::put(vertex_type, *graph, *vi, NODE_PAPER); | ||
| 89 | + } else { | ||
| 90 | + //Author | ||
| 91 | + boost::put(vertex_type, *graph, *vi, NODE_AUTHOR); | ||
| 92 | + } | ||
| 93 | + | ||
| 85 | ++i; | 94 | ++i; |
| 86 | } | 95 | } |
| 87 | qDebug() << "* set vertex property end"; | 96 | qDebug() << "* set vertex property end"; |
| ... | @@ -249,8 +258,6 @@ void GraphItem::path_highlighting(std::string start, std::string end) | ... | @@ -249,8 +258,6 @@ void GraphItem::path_highlighting(std::string start, std::string end) |
| 249 | n->setColor(QColor(255, 0, 0)); | 258 | n->setColor(QColor(255, 0, 0)); |
| 250 | } | 259 | } |
| 251 | } | 260 | } |
| 252 | - | ||
| 253 | - | ||
| 254 | } | 261 | } |
| 255 | 262 | ||
| 256 | void GraphItem::reset_color() | 263 | void GraphItem::reset_color() | ... | ... |
| ... | @@ -9,31 +9,36 @@ using namespace std; | ... | @@ -9,31 +9,36 @@ using namespace std; |
| 9 | using namespace boost; | 9 | using namespace boost; |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -enum GRAPH_LAYOUT { | 12 | +//enum GRAPH_LAYOUT { |
| 13 | - RANDOM_LAYOUT, | 13 | +// RANDOM_LAYOUT, |
| 14 | - CIRCLE_LAYOUT, | 14 | +// CIRCLE_LAYOUT, |
| 15 | - //KAMADA_KAWAI_LAYOUT, | 15 | +// //KAMADA_KAWAI_LAYOUT, |
| 16 | - FRUCHTERMAN_REINGOLD_LAYOUT //slow | 16 | +// FRUCHTERMAN_REINGOLD_LAYOUT //slow |
| 17 | -}; | 17 | +//}; |
| 18 | + | ||
| 18 | /** | 19 | /** |
| 19 | * Constants | 20 | * Constants |
| 20 | */ | 21 | */ |
| 21 | -const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; | 22 | +//const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; |
| 22 | -const int SCREEN_SIZE = 300; | 23 | +//const int SCREEN_SIZE = 300; |
| 23 | -const int NODE_LIMIT = 100; | 24 | +//const int NODE_LIMIT = 100; |
| 24 | - | 25 | +//const boost::regex paper_reg("(conf|journals).*"); |
| 25 | 26 | ||
| 26 | enum vertex_position_t { vertex_position }; | 27 | enum vertex_position_t { vertex_position }; |
| 28 | +enum vertex_type_t { vertex_type }; | ||
| 27 | namespace boost { | 29 | namespace boost { |
| 28 | BOOST_INSTALL_PROPERTY(vertex, position); | 30 | BOOST_INSTALL_PROPERTY(vertex, position); |
| 31 | + BOOST_INSTALL_PROPERTY(vertex, type); | ||
| 29 | } | 32 | } |
| 30 | typedef square_topology<>::point_type point; | 33 | typedef square_topology<>::point_type point; |
| 31 | struct simple_edge { | 34 | struct simple_edge { |
| 32 | int first, second; | 35 | int first, second; |
| 33 | }; | 36 | }; |
| 37 | + | ||
| 34 | typedef boost::property<vertex_index_t, int, | 38 | typedef boost::property<vertex_index_t, int, |
| 35 | boost::property<vertex_name_t, std::string, | 39 | boost::property<vertex_name_t, std::string, |
| 36 | - boost::property<vertex_position_t, point>> | 40 | + boost::property<vertex_position_t, point, |
| 41 | + boost::property<vertex_type_t, int>>> | ||
| 37 | > VertexProperties; | 42 | > VertexProperties; |
| 38 | typedef adjacency_list< | 43 | typedef adjacency_list< |
| 39 | listS, //outEdgeList | 44 | listS, //outEdgeList | ... | ... |
| ... | @@ -2,21 +2,16 @@ | ... | @@ -2,21 +2,16 @@ |
| 2 | #include "PaperGraphWidget.h" | 2 | #include "PaperGraphWidget.h" |
| 3 | #include "MainWindow.h" | 3 | #include "MainWindow.h" |
| 4 | 4 | ||
| 5 | -/** | 5 | +//const char* PAPER_FILENAME = "dblp-paper.txt"; |
| 6 | - * Constants | ||
| 7 | - */ | ||
| 8 | -const char* PAPER_FILENAME = "dblp-paper.txt"; | ||
| 9 | 6 | ||
| 10 | int main(int argc, char *argv[]) | 7 | int main(int argc, char *argv[]) |
| 11 | { | 8 | { |
| 12 | QApplication app(argc, argv); | 9 | QApplication app(argc, argv); |
| 13 | 10 | ||
| 14 | - //PaperGraphWidget w; | ||
| 15 | MainWindow m; | 11 | MainWindow m; |
| 16 | 12 | ||
| 17 | try { | 13 | try { |
| 18 | ifstream fin(PAPER_FILENAME); | 14 | ifstream fin(PAPER_FILENAME); |
| 19 | - //w.print_graph(fin); | ||
| 20 | m.print_graph(fin); | 15 | m.print_graph(fin); |
| 21 | fin.close(); | 16 | fin.close(); |
| 22 | } catch (const std::exception& e) { | 17 | } catch (const std::exception& e) { |
| ... | @@ -24,7 +19,6 @@ int main(int argc, char *argv[]) | ... | @@ -24,7 +19,6 @@ int main(int argc, char *argv[]) |
| 24 | return EXIT_FAILURE; | 19 | return EXIT_FAILURE; |
| 25 | } | 20 | } |
| 26 | 21 | ||
| 27 | - //w.show(); | ||
| 28 | m.show(); | 22 | m.show(); |
| 29 | 23 | ||
| 30 | return app.exec(); | 24 | return app.exec(); | ... | ... |
| ... | @@ -38,4 +38,26 @@ | ... | @@ -38,4 +38,26 @@ |
| 38 | #include <vector> | 38 | #include <vector> |
| 39 | 39 | ||
| 40 | using namespace boost; | 40 | using namespace boost; |
| 41 | -using namespace std; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 41 | +using namespace std; | ||
| 42 | + | ||
| 43 | +#define NODE_PAPER 1 | ||
| 44 | +#define NODE_AUTHOR 2 | ||
| 45 | + | ||
| 46 | +namespace { | ||
| 47 | + enum GRAPH_LAYOUT { | ||
| 48 | + RANDOM_LAYOUT, | ||
| 49 | + CIRCLE_LAYOUT, | ||
| 50 | + //KAMADA_KAWAI_LAYOUT, | ||
| 51 | + FRUCHTERMAN_REINGOLD_LAYOUT //slow | ||
| 52 | + }; | ||
| 53 | + | ||
| 54 | + const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; | ||
| 55 | + const int SCREEN_SIZE = 300; | ||
| 56 | + const int NODE_LIMIT = 100; | ||
| 57 | + | ||
| 58 | + const char* PAPER_FILENAME = "dblp-paper.txt"; | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +namespace boost { | ||
| 62 | + const regex paper_reg("(conf|journals).*"); | ||
| 63 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment