Toggle navigation
Toggle navigation
This project
Loading...
Sign in
조성현
/
graph-visualization
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
조성현
2017-06-21 18:05:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c35c7fc308768279fffc3139fe633a96c3e65542
c35c7fc3
1 parent
cdca4915
피인용 카운트 추가
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
42 deletions
PaperGraph/GraphItem.cpp
PaperGraph/PaperGraph.vcxproj.filters
PaperGraph/json_processor.cpp
PaperGraph/json_processor.h
PaperGraph/main.cpp
PaperGraph/stdafx.h
PaperGraph/GraphItem.cpp
View file @
c35c7fc
...
...
@@ -35,6 +35,7 @@ void GraphItem::read_more()
auto
node_position_map
=
boost
::
get
(
vertex_position
,
*
graph
);
auto
node_label_map
=
boost
::
get
(
vertex_name
,
*
graph
);
auto
node_type_map
=
boost
::
get
(
vertex_type
,
*
graph
);
auto
node_citation_map
=
boost
::
get
(
vertex_citation
,
*
graph
);
int
line_cnt
=
0
;
qDebug
()
<<
"* graph reading start"
;
...
...
@@ -110,15 +111,49 @@ void GraphItem::read_more()
//qDebug() << "** index: " << i << ", name: " << node_label.c_str();
//node type
설정
//node type
에 따라
if
(
boost
::
regex_match
(
node_label
,
paper_reg
))
{
//Paper
//Paper일 경우
//vertex type 설정
boost
::
put
(
vertex_type
,
*
graph
,
*
vi
,
NODE_TYPE
::
NODE_PAPER
);
//citation counting
//bibtex 다운로드
std
::
string
dblp_url
=
std
::
string
(
"http://dblp.uni-trier.de/rec/bib1/"
)
+
node_label
;
_curl_processor
.
set_url
(
dblp_url
.
c_str
());
_curl_processor
.
perform
();
//bibtex 파싱
_bibtex_processor
.
read
(
_curl_processor
.
get_buffer
());
std
::
string
doi
;
if
(
!
_bibtex_processor
.
get_value
(
"doi"
,
doi
))
{
//doi가 없는 경우
node_citation_map
[
*
vi
]
=
0
;
//citation count 0으로 설정
}
else
{
//doi가 존재하는 경우
std
::
string
json_address
=
std
::
string
(
"http://api.crossref.org/works/"
)
+
doi
;
_curl_processor
.
set_url
(
json_address
.
c_str
());
_curl_processor
.
perform
();
_json_processor
.
read_json
(
_curl_processor
.
get_buffer
());
if
(
!
_json_processor
.
is_ok
())
{
node_citation_map
[
*
vi
]
=
0
;
}
else
{
node_citation_map
[
*
vi
]
=
_json_processor
.
get_citation_count
();
}
}
}
else
{
//Author
boost
::
put
(
vertex_type
,
*
graph
,
*
vi
,
NODE_TYPE
::
NODE_AUTHOR
);
}
//counter
//printf("%d end: %s\n", i, node_label.c_str());
++
i
;
}
qDebug
()
<<
"* set vertex property end"
;
...
...
@@ -876,13 +911,22 @@ void GraphItem::test()
{
qDebug
(
"* test action start"
);
//count 테스트
//전체노드 색 변경
for
(
auto
&
n
:
nodeList
)
{
n
->
setColor
(
Qt
::
lightGray
);
}
//citation 디버그
auto
node_citation_map
=
boost
::
get
(
vertex_citation
,
*
graph
);
auto
node_label_map
=
boost
::
get
(
vertex_name
,
*
graph
);
auto
node_type_map
=
boost
::
get
(
vertex_type
,
*
graph
);
vertex_iterator
vi
,
vi_end
;
for
(
boost
::
tie
(
vi
,
vi_end
)
=
vertices
(
*
graph
);
vi
!=
vi_end
;
++
vi
)
{
if
(
node_type_map
[
*
vi
]
!=
NODE_TYPE
::
NODE_PAPER
)
continue
;
printf
(
"%s, %d
\n
"
,
node_label_map
[
*
vi
].
c_str
(),
node_citation_map
[
*
vi
]);
}
qDebug
(
"* test action end"
);
...
...
PaperGraph/PaperGraph.vcxproj.filters
View file @
c35c7fc
...
...
@@ -89,6 +89,9 @@
<ClCompile Include="bibtex_processor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="json_processor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="PaperGraphWidget.h">
...
...
@@ -123,5 +126,8 @@
<ClInclude Include="bibtex_processor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="json_processor.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
...
...
PaperGraph/json_processor.cpp
0 → 100644
View file @
c35c7fc
#include "stdafx.h"
#include "json_processor.h"
//////////////////////////////////////////////////////////////////
// constructor, destructor
//////////////////////////////////////////////////////////////////
json_processor
::
json_processor
()
{
}
json_processor
::~
json_processor
()
{
//document.Clear();
}
//////////////////////////////////////////////////////////////////
// methods
//////////////////////////////////////////////////////////////////
void
json_processor
::
read_json
(
const
std
::
string
&
json_str
)
{
document
.
Parse
(
json_str
.
c_str
());
}
bool
json_processor
::
is_ok
()
{
rapidjson
::
Value
&
value_status
=
document
[
"status"
];
std
::
string
status_str
=
value_status
.
GetString
();
return
(
status_str
==
"ok"
);
}
int
json_processor
::
get_citation_count
()
{
//원래는 json_processor를 상속받는 클래스를 만들어야 하지만
//빠른 구현을 위해서 대충 이 클래스에 구현
rapidjson
::
Value
&
citation_count
=
document
[
"message"
][
"is-referenced-by-count"
];
return
citation_count
.
GetInt
();
}
\ No newline at end of file
PaperGraph/json_processor.h
0 → 100644
View file @
c35c7fc
#pragma once
#include "stdafx.h"
class
json_processor
{
//private var
private:
rapidjson
::
Document
document
;
//constructor, destructor
public:
json_processor
();
~
json_processor
();
//methods
public:
void
read_json
(
const
std
::
string
&
json_str
);
bool
is_ok
();
int
get_citation_count
();
};
PaperGraph/main.cpp
View file @
c35c7fc
...
...
@@ -3,42 +3,46 @@
#include "MainWindow.h"
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
1
)
{
_curl_processor
.
set_url
(
"http://dblp.uni-trier.de/rec/bib1/conf/sbrn/WedemannCD06"
);
_curl_processor
.
perform
();
printf
(
"%s"
,
_curl_processor
.
get_buffer
().
c_str
());
_bibtex_processor
.
read
(
_curl_processor
.
get_buffer
());
std
::
string
doi
;
_bibtex_processor
.
get_value
(
"doi"
,
doi
);
std
::
string
address
=
std
::
string
(
"http://api.crossref.org/works/"
)
+
doi
;
_curl_processor
.
set_url
(
address
.
c_str
());
_curl_processor
.
perform
();
printf
(
"json: %s
\n
"
,
_curl_processor
.
get_buffer
().
c_str
());
//rapidjson test
rapidjson
::
Document
d
;
d
.
Parse
(
_curl_processor
.
get_buffer
().
c_str
());
rapidjson
::
Value
&
value_status
=
d
[
"status"
];
std
::
string
status_str
=
value_status
.
GetString
();
printf
(
"status: %s
\n
"
,
status_str
.
c_str
());
//if (status_str != "ok") {
// printf("status: %s\n", status_str.c_str());
// printf("not ok\n");
// return 1;
//}
rapidjson
::
Value
&
value_message
=
d
[
"message"
];
rapidjson
::
Value
&
citation_count
=
value_message
[
"is-referenced-by-count"
];
int
cit_cnt
=
citation_count
.
GetInt
();
printf
(
"citation: %d
\n
"
,
cit_cnt
);
return
0
;
}
//if (1) {
// _curl_processor.set_url("http://dblp.uni-trier.de/rec/bib1/conf/sbrn/WedemannCD06");
// _curl_processor.perform();
// printf("%s", _curl_processor.get_buffer().c_str());
//
// _bibtex_processor.read(_curl_processor.get_buffer());
// std::string doi;
// _bibtex_processor.get_value("doi", doi);
// std::string address = std::string("http://api.crossref.org/works/")+doi;
// _curl_processor.set_url(address.c_str());
// _curl_processor.perform();
// printf("json: %s\n", _curl_processor.get_buffer().c_str());
// //rapidjson test
// rapidjson::Document d;
// d.Parse(_curl_processor.get_buffer().c_str());
// rapidjson::Value& value_status = d["status"];
// std::string status_str = value_status.GetString();
// printf("status: %s\n", status_str.c_str());
// if (status_str != "ok") {
// printf("status: %s\n", status_str.c_str());
// printf("not ok\n");
// return 1;
// }
// rapidjson::Value& value_message = d["message"];
// rapidjson::Value& citation_count = value_message["is-referenced-by-count"];
// int cit_cnt = citation_count.GetInt();
// printf("citation: %d\n", cit_cnt);
// //
// rapidjson::Value& citation_count2 = d["message"]["is-referenced-by-count"];
// printf("%d\n", citation_count2.GetInt());
// return 0;
//}
QApplication
app
(
argc
,
argv
);
...
...
PaperGraph/stdafx.h
View file @
c35c7fc
...
...
@@ -55,6 +55,7 @@
#include "bibtex_processor.h"
#include "curl_processor.h"
#include "json_processor.h"
using
bibtex
::
BibTeXEntry
;
using
namespace
boost
;
...
...
@@ -93,7 +94,7 @@ typedef boost::property<vertex_index_t, int,
boost
::
property
<
vertex_position_t
,
point
,
//좌표값
boost
::
property
<
vertex_type_t
,
int
,
//타입. enum NODE_TYPE에 정의됨
boost
::
property
<
vertex_record_t
,
int
,
//이웃 노드 개수
boost
::
property
<
vertex_citation_t
,
int
>
boost
::
property
<
vertex_citation_t
,
int
>
//피인용수
>>>>
>
VertexProperties
;
typedef
boost
::
adjacency_list
<
...
...
@@ -122,14 +123,17 @@ namespace {
const
int
LAYOUT_MODE
=
GRAPH_LAYOUT
::
RANDOM_LAYOUT
;
//const int SCREEN_SIZE = 3000;
const
int
SCREEN_SIZE
=
500
;
//const int READ_LINE_UNIT = 2
0; //한 번에 몇 라인을 읽을지
const
int
READ_LINE_UNIT
=
100
;
const
int
READ_LINE_UNIT
=
10
0
;
//한 번에 몇 라인을 읽을지
//
const int READ_LINE_UNIT = 100;
/* curl processor */
curl_processor
_curl_processor
;
/* bibtex processor */
bibtex_processor
_bibtex_processor
;
/* json processor */
json_processor
_json_processor
;
}
/* boost */
...
...
Please
register
or
login
to post a comment