조성현

add pagerank

...@@ -921,6 +921,7 @@ void GraphItem::test() ...@@ -921,6 +921,7 @@ void GraphItem::test()
921 auto node_citation_map = boost::get(vertex_citation, *graph); 921 auto node_citation_map = boost::get(vertex_citation, *graph);
922 auto node_label_map = boost::get(vertex_name, *graph); 922 auto node_label_map = boost::get(vertex_name, *graph);
923 auto node_type_map = boost::get(vertex_type, *graph); 923 auto node_type_map = boost::get(vertex_type, *graph);
924 + auto node_pagerank_map = boost::get(vertex_pagerank, *graph);
924 vertex_iterator vi, vi_end; 925 vertex_iterator vi, vi_end;
925 for (boost::tie(vi, vi_end) = vertices(*graph); vi != vi_end; ++vi) { 926 for (boost::tie(vi, vi_end) = vertices(*graph); vi != vi_end; ++vi) {
926 if (node_type_map[*vi] != NODE_TYPE::NODE_PAPER) continue; 927 if (node_type_map[*vi] != NODE_TYPE::NODE_PAPER) continue;
...@@ -928,6 +929,16 @@ void GraphItem::test() ...@@ -928,6 +929,16 @@ void GraphItem::test()
928 node_citation_map[*vi]); 929 node_citation_map[*vi]);
929 } 930 }
930 931
932 + //page_rank();
933 + qDebug("* pagerank start");
934 + boost::graph::page_rank(*graph, node_pagerank_map);
935 + for (boost::tie(vi, vi_end) = vertices(*graph); vi != vi_end; ++vi) {
936 + printf("%s\t\t%f\n", node_label_map[*vi].c_str(),
937 + node_pagerank_map[*vi]);
938 + }
939 + qDebug("* pagerank end");
940 +
941 +
931 942
932 qDebug("* test action end"); 943 qDebug("* test action end");
933 } 944 }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
27 #include <boost/graph/dijkstra_shortest_paths.hpp> 27 #include <boost/graph/dijkstra_shortest_paths.hpp>
28 #include <boost/graph/fruchterman_reingold.hpp> 28 #include <boost/graph/fruchterman_reingold.hpp>
29 #include <boost/graph/graph_traits.hpp> 29 #include <boost/graph/graph_traits.hpp>
30 +#include <boost/graph/page_rank.hpp>
30 #include <boost/graph/random_layout.hpp> 31 #include <boost/graph/random_layout.hpp>
31 #include <boost/graph/topology.hpp> 32 #include <boost/graph/topology.hpp>
32 #include <boost/regex.hpp> 33 #include <boost/regex.hpp>
...@@ -69,11 +70,13 @@ enum vertex_position_t { vertex_position }; ...@@ -69,11 +70,13 @@ enum vertex_position_t { vertex_position };
69 enum vertex_type_t { vertex_type }; 70 enum vertex_type_t { vertex_type };
70 enum vertex_record_t { vertex_record }; 71 enum vertex_record_t { vertex_record };
71 enum vertex_citation_t { vertex_citation }; 72 enum vertex_citation_t { vertex_citation };
73 +enum vertex_pagerank_t { vertex_pagerank };
72 namespace boost { 74 namespace boost {
73 BOOST_INSTALL_PROPERTY(vertex, position); 75 BOOST_INSTALL_PROPERTY(vertex, position);
74 BOOST_INSTALL_PROPERTY(vertex, type); 76 BOOST_INSTALL_PROPERTY(vertex, type);
75 BOOST_INSTALL_PROPERTY(vertex, record); 77 BOOST_INSTALL_PROPERTY(vertex, record);
76 BOOST_INSTALL_PROPERTY(vertex, citation); 78 BOOST_INSTALL_PROPERTY(vertex, citation);
79 + BOOST_INSTALL_PROPERTY(vertex, pagerank);
77 } 80 }
78 enum NODE_TYPE { 81 enum NODE_TYPE {
79 NODE_PAPER, 82 NODE_PAPER,
...@@ -94,8 +97,9 @@ typedef boost::property<vertex_index_t, int, ...@@ -94,8 +97,9 @@ typedef boost::property<vertex_index_t, int,
94 boost::property<vertex_position_t, point, //좌표값 97 boost::property<vertex_position_t, point, //좌표값
95 boost::property<vertex_type_t, int, //타입. enum NODE_TYPE에 정의됨 98 boost::property<vertex_type_t, int, //타입. enum NODE_TYPE에 정의됨
96 boost::property<vertex_record_t, int, //이웃 노드 개수 99 boost::property<vertex_record_t, int, //이웃 노드 개수
97 - boost::property<vertex_citation_t, int> //피인용수 100 + boost::property<vertex_citation_t, int, //피인용수
98 - >>>> 101 + boost::property<vertex_pagerank_t, double> //페이지랭크 값
102 + >>>>>
99 > VertexProperties; 103 > VertexProperties;
100 typedef boost::adjacency_list< 104 typedef boost::adjacency_list<
101 listS, //outEdgeList 105 listS, //outEdgeList
...@@ -122,9 +126,8 @@ namespace { ...@@ -122,9 +126,8 @@ namespace {
122 const int NODE_SIZE = 4; 126 const int NODE_SIZE = 4;
123 const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT; 127 const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT;
124 //const int SCREEN_SIZE = 3000; 128 //const int SCREEN_SIZE = 3000;
125 - const int SCREEN_SIZE = 500; 129 + const int SCREEN_SIZE = 3000;
126 - const int READ_LINE_UNIT = 100; //한 번에 몇 라인을 읽을지 130 + const int READ_LINE_UNIT = 10; //한 번에 몇 라인을 읽을지
127 - //const int READ_LINE_UNIT = 100;
128 131
129 /* curl processor */ 132 /* curl processor */
130 curl_processor _curl_processor; 133 curl_processor _curl_processor;
......