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-04-17 23:31:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1e191597fa2e4bb25576bd3de3e4f342cc497660
1e191597
1 parent
4ef6d249
person you might know --> test version
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
28 deletions
PaperGraph/GraphItem.cpp
PaperGraph/GraphItem.h
PaperGraph/MainWindow.cpp
PaperGraph/MainWindow.h
PaperGraph/PaperGraphWidget.cpp
PaperGraph/PaperGraphWidget.h
PaperGraph/stdafx.h
PaperGraph/GraphItem.cpp
View file @
1e19159
...
...
@@ -108,7 +108,7 @@ void GraphItem::read_more()
boost
::
put
(
vertex_name
,
*
graph
,
*
vi
,
node_label
);
boost
::
put
(
vertex_record
,
*
graph
,
*
vi
,
0
);
qDebug
()
<<
"** index: "
<<
i
<<
", name: "
<<
node_label
.
c_str
();
//
qDebug() << "** index: " << i << ", name: " << node_label.c_str();
//node type 설정
if
(
boost
::
regex_match
(
node_label
,
paper_reg
))
{
...
...
@@ -268,13 +268,64 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
}
}
void
GraphItem
::
path_highlighting
(
std
::
string
start
,
std
::
string
end
)
void
GraphItem
::
might_know
(
)
{
//path highlight
//nodeList, edgeList 속성을 수정
// 알 수도 있는 연구원 찾기
vertex_iterator
vi
,
vi_end
,
vtarget
;
Graph
::
adjacency_iterator
ai
,
ai_end
;
vector
<
string
>
might_know_vec
;
auto
label
=
get
(
vertex_name
,
*
graph
);
auto
nodeType
=
get
(
vertex_type
,
*
graph
);
// 회색 색칠
for
(
auto
&
n
:
nodeList
)
{
if
(
n
->
getLabel
().
toStdString
()
!=
TARGET_AUTHOR_NAME
)
{
n
->
setColor
(
QColor
(
Qt
::
lightGray
));
}
else
{
n
->
setColor
(
QColor
(
Qt
::
blue
));
}
}
// find target node
for
(
boost
::
tie
(
vi
,
vi_end
)
=
boost
::
vertices
(
*
graph
);
vi
!=
vi_end
;
++
vi
)
{
if
(
label
[
*
vi
]
==
std
::
string
(
TARGET_AUTHOR_NAME
))
{
vtarget
=
vi
;
break
;
}
}
// bfs
//std::queue<vertex_iterator> q;
//q.push(vtarget);
//while (!q.empty()) {
// /*auto next_vi = q.front();
// q.pop();
// if (nodeType[*next_vi] == NODE_TYPE::NODE_PAPER)
// continue;
// for (boost::tie(ai, ai_end) = boost::adjacent_vertices(*next_vi, *graph);
// ai != ai_end; ++ai) {
// if (nodeType[*ai] == NODE_TYPE::NODE_PAPER)
// continue;
// else
// q.push(ai);
// }*/
//}
for
(
boost
::
tie
(
ai
,
ai_end
)
=
boost
::
adjacent_vertices
(
*
vtarget
,
*
graph
);
ai
!=
ai_end
;
++
ai
)
{
might_know_vec
.
push_back
(
label
[
*
ai
]);
}
// highlight
for
(
auto
&
n
:
nodeList
)
{
if
(
n
->
getLabel
()
==
QString
(
"Seongsoo Park"
))
{
n
->
setColor
(
QColor
(
255
,
0
,
0
));
if
(
std
::
find
(
might_know_vec
.
begin
(),
might_know_vec
.
end
(),
n
->
getLabel
().
toStdString
())
!=
might_know_vec
.
end
())
{
//found
n
->
setColor
(
Qt
::
red
);
}
}
}
...
...
@@ -318,20 +369,24 @@ void GraphItem::topK_highlight()
int
record_cnt
=
0
;
for
(
boost
::
tie
(
ai
,
ai_end
)
=
boost
::
adjacent_vertices
(
*
vi
,
*
graph
);
ai
!=
ai_end
;
++
ai
)
{
if
(
nodeType
[
*
v
i
]
==
NODE_TYPE
::
NODE_PAPER
)
{
if
(
nodeType
[
*
a
i
]
==
NODE_TYPE
::
NODE_PAPER
)
{
++
record_cnt
;
}
}
boost
::
put
(
vertex_record
,
*
graph
,
*
vi
,
record_cnt
);
heap
.
push
(
make_pair
(
record_cnt
,
nodeLabel
[
*
vi
]));
//qDebug() << record_cnt;
}
//get top K records
pair
<
int
,
string
>
topk_arr
[
TOP_K
];
for
(
int
i
=
0
;
i
<
TOP_K
;
++
i
)
{
topk_arr
[
i
]
=
heap
.
pop
();
qDebug
()
<<
"topk["
<<
i
<<
"] = "
<<
topk_arr
[
i
].
first
<<
", "
<<
QString
::
fromStdString
(
topk_arr
[
i
].
second
);
}
for
(
auto
&
n
:
nodeList
)
{
auto
label
=
n
->
getLabel
();
...
...
@@ -343,8 +398,6 @@ void GraphItem::topK_highlight()
}
}
}
//delete[] topk_arr;
}
//event handler
...
...
PaperGraph/GraphItem.h
View file @
1e19159
...
...
@@ -26,7 +26,7 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
override
;
//methods
void
path_highlighting
(
std
::
string
start
,
std
::
string
end
);
void
might_know
(
);
void
reset_color
();
void
topK_highlight
();
...
...
PaperGraph/MainWindow.cpp
View file @
1e19159
...
...
@@ -17,7 +17,7 @@ MainWindow::MainWindow(QWidget *parent)
statusBar
()
->
showMessage
(
message
);
setMinimumSize
(
160
,
160
);
resize
(
800
,
60
0
);
resize
(
1200
,
65
0
);
}
MainWindow
::~
MainWindow
()
...
...
@@ -44,9 +44,9 @@ void MainWindow::createActions()
readMoreAct
->
setStatusTip
(
tr
(
"read more lines from file"
));
connect
(
readMoreAct
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
read_more
);
testHighlightAct
=
new
QAction
(
tr
(
"Highlight
"
),
this
);
testHighlightAct
->
setStatusTip
(
tr
(
"Highlighting node
"
));
connect
(
testHighlightAct
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
test_highlighting
);
mightKnowAct
=
new
QAction
(
tr
(
"Might know
"
),
this
);
mightKnowAct
->
setStatusTip
(
tr
(
"highlight a research you might know
"
));
connect
(
mightKnowAct
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
might_know
);
topkAct
=
new
QAction
(
tr
(
"topK"
),
this
);
topkAct
->
setStatusTip
(
tr
(
"highlight who was top k papers"
));
connect
(
topkAct
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
topk
);
...
...
@@ -61,7 +61,7 @@ void MainWindow::createMenus()
fileMenu
->
addAction
(
readMoreAct
);
actionMenu
=
menuBar
()
->
addMenu
(
tr
(
"&Actions"
));
actionMenu
->
addAction
(
testHighlight
Act
);
actionMenu
->
addAction
(
mightKnow
Act
);
actionMenu
->
addAction
(
topkAct
);
actionMenu
->
addAction
(
resetColorAct
);
}
...
...
@@ -75,12 +75,9 @@ void MainWindow::read_more()
graphWidget
->
read_more
();
}
void
MainWindow
::
test_highlighting
()
void
MainWindow
::
might_know
()
{
/*QMessageBox::information(this, "test",
"test: "+QString::number(11));*/
graphWidget
->
path_highlight
();
//graphWidget->update();
graphWidget
->
might_know
();
}
void
MainWindow
::
topk
()
...
...
PaperGraph/MainWindow.h
View file @
1e19159
...
...
@@ -22,7 +22,7 @@ private:
QMenu
*
fileMenu
;
QAction
*
readMoreAct
;
QMenu
*
actionMenu
;
QAction
*
testHighlight
Act
;
QAction
*
mightKnow
Act
;
QAction
*
topkAct
;
QAction
*
resetColorAct
;
...
...
@@ -32,7 +32,7 @@ private:
private
slots
:
void
read_more
();
void
test_highlighting
();
void
might_know
();
void
topk
();
void
reset_color
();
};
...
...
PaperGraph/PaperGraphWidget.cpp
View file @
1e19159
...
...
@@ -54,9 +54,9 @@ void PaperGraphWidget::read_more()
scene
->
update
();
}
void
PaperGraphWidget
::
path_highlight
()
void
PaperGraphWidget
::
might_know
()
{
graphItem
->
path_highlighting
(
std
::
string
(
""
),
std
::
string
(
""
)
);
graphItem
->
might_know
(
);
scene
->
update
();
}
...
...
PaperGraph/PaperGraphWidget.h
View file @
1e19159
...
...
@@ -16,7 +16,7 @@ public:
//main window slots
void
read_more
();
void
path_highlight
();
void
might_know
();
void
topk
();
void
reset_color
();
...
...
PaperGraph/stdafx.h
View file @
1e19159
...
...
@@ -105,12 +105,14 @@ namespace {
/* visualization */
const
int
NODE_SIZE
=
4
;
const
int
LAYOUT_MODE
=
GRAPH_LAYOUT
::
RANDOM_LAYOUT
;
const
int
SCREEN_SIZE
=
10
00
;
const
int
READ_LINE_UNIT
=
5
;
//한 번에 몇 라인을 읽을지
const
int
SCREEN_SIZE
=
5
00
;
const
int
READ_LINE_UNIT
=
20
;
//한 번에 몇 라인을 읽을지
/* topK */
const
int
TOP_K
=
10
;
//상위 몇 개 아이템에 대해 highlight 할 지
const
int
TOP_K
=
5
;
//상위 몇 개 아이템에 대해 highlight 할 지
/* a research you might know */
const
char
*
TARGET_AUTHOR_NAME
=
"Shuichi Itoh"
;
}
/* boost */
...
...
Please
register
or
login
to post a comment