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-05-20 22:02:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
98311824f1cfaf5c4f9f3475dbc1f0b92c950ce2
98311824
1 parent
b156f5ce
add shortest path finding (in experiment)
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
13 deletions
PaperGraph/GraphItem.cpp
PaperGraph/GraphItem.h
PaperGraph/PaperGraphWidget.cpp
PaperGraph/GraphItem.cpp
View file @
9831182
...
...
@@ -310,8 +310,10 @@ void GraphItem::reset_color()
}
}
void
GraphItem
::
topK_highlight
()
void
GraphItem
::
topK_highlight
_with_total
()
{
// 전체 그래프 기준 topK highlight
// 저자 노드별 실적 계산
vertex_iterator
vi
,
vi_end
;
Graph
::
adjacency_iterator
ai
,
ai_end
;
...
...
@@ -374,29 +376,67 @@ void GraphItem::test()
qDebug
(
"* path highlighting start"
);
vertex_iterator
vi
,
vi_end
;
//find start, end node's id
int
start_idx
,
end_idx
;
auto
vertex_idx
=
boost
::
get
(
vertex_index
,
*
graph
);
auto
nodeLabel
=
boost
::
get
(
vertex_name
,
*
graph
);
int
start_idx
=-
1
,
end_idx
=-
1
;
for
(
boost
::
tie
(
vi
,
vi_end
)
=
vertices
(
*
graph
);
vi
!=
vi_end
;
++
vi
)
{
string
node_name
=
boost
::
get
(
vertex_name
,
*
graph
,
*
vi
);
if
(
node_name
==
"Seong Chul Cho"
)
{
start_idx
=
boost
::
get
(
vertex_index
,
*
graph
,
*
vi
);
}
else
if
(
node_name
==
"Hyung Jin Kim"
)
{
end_idx
=
boost
::
get
(
vertex_index
,
*
graph
,
*
vi
);
//string node_name = boost::get(vertex_name, *graph, *vi);
const
string
&
node_name
=
nodeLabel
[
*
vi
];
if
(
node_name
==
"Jung Gon Kim"
)
{
start_idx
=
vertex_idx
[
*
vi
];
}
else
if
(
node_name
==
"Yong-Jin Kim"
)
{
end_idx
=
vertex_idx
[
*
vi
];
}
}
if
(
start_idx
==-
1
||
end_idx
==-
1
)
{
qDebug
()
<<
start_idx
<<
" "
<<
end_idx
;
qDebug
(
"no target node"
);
return
;
}
else
if
(
start_idx
==
end_idx
)
{
qDebug
(
"start and end node are same!"
);
return
;
}
vector
<
vertex_descriptor
>
parents
(
num_vertices
(
*
graph
));
vector
<
double
>
distances
(
num_vertices
(
*
graph
));
vertex_descriptor
start_vertex
=
boost
::
vertex
(
start_idx
,
*
graph
);
//shortest path using dijkstra
boost
::
dijkstra_shortest_paths
(
*
graph
,
start_vertex
,
predecessor_map
(
boost
::
make_iterator_property_map
(
parents
.
begin
(),
boost
::
get
(
boost
::
vertex_index
,
*
graph
))).
distance_map
(
boost
::
make_iterator_property_map
(
distances
.
begin
(),
get
(
boost
::
vertex_index
,
*
graph
))));
//check distances
//qDebug() << "dist: " << distances[end_idx];
//qDebug();
//for (int i = 0; i < distances.size(); ++i) {
// qDebug() << "dist[" << i << "]: " << distances[i];
//}
//qDebug();
if
(
distances
[
end_idx
]
>=
whole_node_cnt
)
{
//no path (dist == 0)
qDebug
()
<<
"no path!"
;
return
;
}
//path finding
qDebug
(
"* path finding start"
);
vertex_descriptor
current
=
boost
::
vertex
(
end_idx
,
*
graph
);
while
(
current
!=
boost
::
vertex
(
start_idx
,
*
graph
))
{
qDebug
()
<<
"end: "
<<
nodeLabel
[
current
].
c_str
();
while
(
1
)
{
current
=
parents
[
vertex_idx
[
current
]];
qDebug
()
<<
nodeLabel
[
current
].
c_str
();
if
(
current
==
start_vertex
)
break
;
}
qDebug
(
"* path finding end"
);
qDebug
(
"* path highlighting start"
);
qDebug
(
"* path highlighting end"
);
}
...
...
PaperGraph/GraphItem.h
View file @
9831182
...
...
@@ -28,7 +28,7 @@ public:
//methods
void
might_know
();
void
reset_color
();
void
topK_highlight
();
void
topK_highlight
_with_total
();
//test
void
test
();
...
...
@@ -41,8 +41,6 @@ protected:
private
:
ifstream
fin
;
bm_type
node_ids
;
//vector<pair<string, string>> edges;
//vector<pair<int, int>> edges_indexes;
vector
<
vertex_descriptor
>
vdes
;
int
whole_node_cnt
=
0
;
...
...
PaperGraph/PaperGraphWidget.cpp
View file @
9831182
...
...
@@ -58,7 +58,7 @@ void PaperGraphWidget::might_know()
void
PaperGraphWidget
::
topk
()
{
graphItem
->
topK_highlight
();
graphItem
->
topK_highlight
_with_total
();
scene
->
update
();
}
...
...
Please
register
or
login
to post a comment