Showing
3 changed files
with
54 additions
and
51 deletions
... | @@ -23,9 +23,9 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) | ... | @@ -23,9 +23,9 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) |
23 | 23 | ||
24 | //String <--> int 양방향 변환을 위해 bidirectional map 상숑 | 24 | //String <--> int 양방향 변환을 위해 bidirectional map 상숑 |
25 | //map<string, int> -> <vertex label, vertex index> | 25 | //map<string, int> -> <vertex label, vertex index> |
26 | - typedef boost::bimap<string, int> bm_type; | 26 | + /*typedef boost::bimap<string, int> bm_type;*/ |
27 | - bm_type node_ids; | 27 | + /*bm_type node_ids; |
28 | - vector<simple_edge> edges_indexes; //int로 변환된 edge | 28 | + vector<simple_edge> edges_indexes*/; //int로 변환된 edge |
29 | 29 | ||
30 | int node_cnt = 0; | 30 | int node_cnt = 0; |
31 | int line_cnt = 0; | 31 | int line_cnt = 0; |
... | @@ -76,8 +76,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) | ... | @@ -76,8 +76,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) |
76 | 76 | ||
77 | //set index property | 77 | //set index property |
78 | qDebug() << "* set vertex property start"; | 78 | qDebug() << "* set vertex property start"; |
79 | - typedef typename graph_traits<Graph>::edge_iterator edge_iterator; | ||
80 | - typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator; | ||
81 | vertex_iterator vi, vi_end; | 79 | vertex_iterator vi, vi_end; |
82 | int i = 0; | 80 | int i = 0; |
83 | for (boost::tie(vi, vi_end)=vertices(*graph); vi!=vi_end; ++vi) { | 81 | for (boost::tie(vi, vi_end)=vertices(*graph); vi!=vi_end; ++vi) { |
... | @@ -143,7 +141,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) | ... | @@ -143,7 +141,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) |
143 | //예제 코드: http://www.boost.org/doc/libs/1_63_0/libs/graph/test/layout_test.cpp | 141 | //예제 코드: http://www.boost.org/doc/libs/1_63_0/libs/graph/test/layout_test.cpp |
144 | //(-> 콘솔 기반) | 142 | //(-> 콘솔 기반) |
145 | qDebug() << "* make graph layout start"; | 143 | qDebug() << "* make graph layout start"; |
146 | - typedef square_topology<> Topology; | ||
147 | minstd_rand gen; | 144 | minstd_rand gen; |
148 | Topology topology(gen, (double)SCREEN_SIZE); | 145 | Topology topology(gen, (double)SCREEN_SIZE); |
149 | Topology::point_type origin; | 146 | Topology::point_type origin; |
... | @@ -176,14 +173,11 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) | ... | @@ -176,14 +173,11 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines) |
176 | 173 | ||
177 | 174 | ||
178 | //add edges | 175 | //add edges |
179 | - typedef square_topology<> Topology; | ||
180 | - typedef typename Topology::point_type Point; | ||
181 | auto position = get(vertex_position, *graph); | 176 | auto position = get(vertex_position, *graph); |
182 | auto label = get(vertex_name, *graph); | 177 | auto label = get(vertex_name, *graph); |
183 | auto nodeType = get(vertex_type, *graph); | 178 | auto nodeType = get(vertex_type, *graph); |
184 | 179 | ||
185 | - typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor; | 180 | + edge_iterator ei, ei_end; |
186 | - typename graph_traits<Graph>::edge_iterator ei, ei_end; | ||
187 | vertex_descriptor u, v; | 181 | vertex_descriptor u, v; |
188 | for (boost::tie(ei, ei_end)=boost::edges(*graph); ei!=ei_end; ++ei) { | 182 | for (boost::tie(ei, ei_end)=boost::edges(*graph); ei!=ei_end; ++ei) { |
189 | u = source(*ei, *graph); | 183 | u = source(*ei, *graph); | ... | ... |
... | @@ -9,33 +9,6 @@ using namespace std; | ... | @@ -9,33 +9,6 @@ using namespace std; |
9 | using namespace boost; | 9 | using namespace boost; |
10 | 10 | ||
11 | 11 | ||
12 | -enum vertex_position_t { vertex_position }; | ||
13 | -enum vertex_type_t { vertex_type }; | ||
14 | -namespace boost { | ||
15 | - BOOST_INSTALL_PROPERTY(vertex, position); | ||
16 | - BOOST_INSTALL_PROPERTY(vertex, type); | ||
17 | -} | ||
18 | -typedef square_topology<>::point_type point; | ||
19 | -struct simple_edge { | ||
20 | - int first, second; | ||
21 | -}; | ||
22 | - | ||
23 | -typedef boost::property<vertex_index_t, int, | ||
24 | - boost::property<vertex_name_t, std::string, | ||
25 | - boost::property<vertex_position_t, point, | ||
26 | - boost::property<vertex_type_t, int>>> | ||
27 | -> VertexProperties; | ||
28 | -typedef adjacency_list< | ||
29 | - listS, //outEdgeList | ||
30 | - listS, //VertexList | ||
31 | - undirectedS, | ||
32 | - //vertex properties | ||
33 | - VertexProperties, | ||
34 | - //edge properties | ||
35 | - boost::property<edge_weight_t, double> | ||
36 | -> Graph; | ||
37 | - | ||
38 | - | ||
39 | class GraphItem | 12 | class GraphItem |
40 | : public QGraphicsItem | 13 | : public QGraphicsItem |
41 | { | 14 | { |
... | @@ -57,6 +30,8 @@ protected: | ... | @@ -57,6 +30,8 @@ protected: |
57 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; | 30 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
58 | 31 | ||
59 | private: | 32 | private: |
33 | + bm_type node_ids; | ||
34 | + vector<simple_edge> edges_indexes; | ||
60 | Graph *graph = nullptr; | 35 | Graph *graph = nullptr; |
61 | QList<NodeItem *> nodeList; | 36 | QList<NodeItem *> nodeList; |
62 | QList<EdgeItem *> edgeList; | 37 | QList<EdgeItem *> edgeList; | ... | ... |
... | @@ -40,21 +40,54 @@ | ... | @@ -40,21 +40,54 @@ |
40 | using namespace boost; | 40 | using namespace boost; |
41 | using namespace std; | 41 | using namespace std; |
42 | 42 | ||
43 | -/* constants */ | 43 | +/* enums */ |
44 | -namespace { | 44 | +enum vertex_position_t { vertex_position }; |
45 | - /* enums */ | 45 | +enum vertex_type_t { vertex_type }; |
46 | - enum NODE_TYPE { | 46 | +namespace boost { |
47 | - NODE_PAPER, | 47 | + BOOST_INSTALL_PROPERTY(vertex, position); |
48 | - NODE_AUTHOR | 48 | + BOOST_INSTALL_PROPERTY(vertex, type); |
49 | - }; | 49 | +} |
50 | +enum NODE_TYPE { | ||
51 | + NODE_PAPER, | ||
52 | + NODE_AUTHOR | ||
53 | +}; | ||
54 | +enum GRAPH_LAYOUT { | ||
55 | + RANDOM_LAYOUT, | ||
56 | + CIRCLE_LAYOUT, | ||
57 | + //KAMADA_KAWAI_LAYOUT, | ||
58 | + FRUCHTERMAN_REINGOLD_LAYOUT //slow | ||
59 | +}; | ||
50 | 60 | ||
51 | - enum GRAPH_LAYOUT { | 61 | +/* typedef */ |
52 | - RANDOM_LAYOUT, | 62 | +typedef boost::bimap<string, int> bm_type; |
53 | - CIRCLE_LAYOUT, | 63 | +typedef square_topology<>::point_type point; |
54 | - //KAMADA_KAWAI_LAYOUT, | 64 | +typedef boost::property<vertex_index_t, int, |
55 | - FRUCHTERMAN_REINGOLD_LAYOUT //slow | 65 | + boost::property<vertex_name_t, std::string, |
56 | - }; | 66 | + boost::property<vertex_position_t, point, |
67 | + boost::property<vertex_type_t, int>>> | ||
68 | + > VertexProperties; | ||
69 | +typedef boost::adjacency_list< | ||
70 | + listS, //outEdgeList | ||
71 | + listS, //VertexList | ||
72 | + undirectedS, | ||
73 | + //vertex properties | ||
74 | + VertexProperties, | ||
75 | + //edge properties | ||
76 | + boost::property<edge_weight_t, double> | ||
77 | +> Graph; | ||
78 | +typedef typename graph_traits<Graph>::edge_iterator edge_iterator; | ||
79 | +typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator; | ||
80 | +typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor; | ||
81 | +typedef square_topology<> Topology; | ||
82 | +typedef typename Topology::point_type Point; | ||
57 | 83 | ||
84 | +/* structs */ | ||
85 | +struct simple_edge { | ||
86 | + int first, second; | ||
87 | +}; | ||
88 | + | ||
89 | +/* constants */ | ||
90 | +namespace { | ||
58 | /* file io */ | 91 | /* file io */ |
59 | const char* PAPER_FILENAME = "dblp-paper.txt"; | 92 | const char* PAPER_FILENAME = "dblp-paper.txt"; |
60 | 93 | ||
... | @@ -65,10 +98,11 @@ namespace { | ... | @@ -65,10 +98,11 @@ namespace { |
65 | const int READ_LINE_UNIT = 100; //한 번에 몇 라인을 읽을지 | 98 | const int READ_LINE_UNIT = 100; //한 번에 몇 라인을 읽을지 |
66 | 99 | ||
67 | /* topK */ | 100 | /* topK */ |
68 | - const int topK = 10; //상위 몇 개 아이템에 대해 | 101 | + const int TOP_K = 10; //상위 몇 개 아이템에 대해 할 지 |
69 | 102 | ||
70 | } | 103 | } |
71 | 104 | ||
105 | + | ||
72 | namespace boost { | 106 | namespace boost { |
73 | const boost::regex paper_reg("(conf|journals).*"); | 107 | const boost::regex paper_reg("(conf|journals).*"); |
74 | } | 108 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment