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 20:05:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
af4e861ff8a8eab47c56be117886ec3928982354
af4e861f
1 parent
e619f46f
variable arrange
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
51 deletions
PaperGraph/GraphItem.cpp
PaperGraph/GraphItem.h
PaperGraph/stdafx.h
PaperGraph/GraphItem.cpp
View file @
af4e861
...
...
@@ -23,9 +23,9 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines)
//String <--> int 양방향 변환을 위해 bidirectional map 상숑
//map<string, int> -> <vertex label, vertex index>
typedef
boost
::
bimap
<
string
,
int
>
bm_type
;
bm_type
node_ids
;
vector
<
simple_edge
>
edges_indexes
;
//int로 변환된 edge
/*typedef boost::bimap<string, int> bm_type;*/
/*
bm_type node_ids;
vector<simple_edge> edges_indexes
*/
;
//int로 변환된 edge
int
node_cnt
=
0
;
int
line_cnt
=
0
;
...
...
@@ -76,8 +76,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines)
//set index property
qDebug
()
<<
"* set vertex property start"
;
typedef
typename
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
typedef
typename
graph_traits
<
Graph
>::
vertex_iterator
vertex_iterator
;
vertex_iterator
vi
,
vi_end
;
int
i
=
0
;
for
(
boost
::
tie
(
vi
,
vi_end
)
=
vertices
(
*
graph
);
vi
!=
vi_end
;
++
vi
)
{
...
...
@@ -143,7 +141,6 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines)
//예제 코드: http://www.boost.org/doc/libs/1_63_0/libs/graph/test/layout_test.cpp
//(-> 콘솔 기반)
qDebug
()
<<
"* make graph layout start"
;
typedef
square_topology
<>
Topology
;
minstd_rand
gen
;
Topology
topology
(
gen
,
(
double
)
SCREEN_SIZE
);
Topology
::
point_type
origin
;
...
...
@@ -176,14 +173,11 @@ GraphItem::GraphItem(ifstream& fin, int numOfLines)
//add edges
typedef
square_topology
<>
Topology
;
typedef
typename
Topology
::
point_type
Point
;
auto
position
=
get
(
vertex_position
,
*
graph
);
auto
label
=
get
(
vertex_name
,
*
graph
);
auto
nodeType
=
get
(
vertex_type
,
*
graph
);
typedef
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex_descriptor
;
typename
graph_traits
<
Graph
>::
edge_iterator
ei
,
ei_end
;
edge_iterator
ei
,
ei_end
;
vertex_descriptor
u
,
v
;
for
(
boost
::
tie
(
ei
,
ei_end
)
=
boost
::
edges
(
*
graph
);
ei
!=
ei_end
;
++
ei
)
{
u
=
source
(
*
ei
,
*
graph
);
...
...
PaperGraph/GraphItem.h
View file @
af4e861
...
...
@@ -9,33 +9,6 @@ using namespace std;
using
namespace
boost
;
enum
vertex_position_t
{
vertex_position
};
enum
vertex_type_t
{
vertex_type
};
namespace
boost
{
BOOST_INSTALL_PROPERTY
(
vertex
,
position
);
BOOST_INSTALL_PROPERTY
(
vertex
,
type
);
}
typedef
square_topology
<>::
point_type
point
;
struct
simple_edge
{
int
first
,
second
;
};
typedef
boost
::
property
<
vertex_index_t
,
int
,
boost
::
property
<
vertex_name_t
,
std
::
string
,
boost
::
property
<
vertex_position_t
,
point
,
boost
::
property
<
vertex_type_t
,
int
>>>
>
VertexProperties
;
typedef
adjacency_list
<
listS
,
//outEdgeList
listS
,
//VertexList
undirectedS
,
//vertex properties
VertexProperties
,
//edge properties
boost
::
property
<
edge_weight_t
,
double
>
>
Graph
;
class
GraphItem
:
public
QGraphicsItem
{
...
...
@@ -57,6 +30,8 @@ protected:
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
override
;
private
:
bm_type
node_ids
;
vector
<
simple_edge
>
edges_indexes
;
Graph
*
graph
=
nullptr
;
QList
<
NodeItem
*>
nodeList
;
QList
<
EdgeItem
*>
edgeList
;
...
...
PaperGraph/stdafx.h
View file @
af4e861
...
...
@@ -40,21 +40,54 @@
using
namespace
boost
;
using
namespace
std
;
/* constants */
namespace
{
/* enums */
enum
NODE_TYPE
{
NODE_PAPER
,
NODE_AUTHOR
};
/* enums */
enum
vertex_position_t
{
vertex_position
};
enum
vertex_type_t
{
vertex_type
};
namespace
boost
{
BOOST_INSTALL_PROPERTY
(
vertex
,
position
);
BOOST_INSTALL_PROPERTY
(
vertex
,
type
);
}
enum
NODE_TYPE
{
NODE_PAPER
,
NODE_AUTHOR
};
enum
GRAPH_LAYOUT
{
RANDOM_LAYOUT
,
CIRCLE_LAYOUT
,
//KAMADA_KAWAI_LAYOUT,
FRUCHTERMAN_REINGOLD_LAYOUT
//slow
};
enum
GRAPH_LAYOUT
{
RANDOM_LAYOUT
,
CIRCLE_LAYOUT
,
//KAMADA_KAWAI_LAYOUT,
FRUCHTERMAN_REINGOLD_LAYOUT
//slow
};
/* typedef */
typedef
boost
::
bimap
<
string
,
int
>
bm_type
;
typedef
square_topology
<>::
point_type
point
;
typedef
boost
::
property
<
vertex_index_t
,
int
,
boost
::
property
<
vertex_name_t
,
std
::
string
,
boost
::
property
<
vertex_position_t
,
point
,
boost
::
property
<
vertex_type_t
,
int
>>>
>
VertexProperties
;
typedef
boost
::
adjacency_list
<
listS
,
//outEdgeList
listS
,
//VertexList
undirectedS
,
//vertex properties
VertexProperties
,
//edge properties
boost
::
property
<
edge_weight_t
,
double
>
>
Graph
;
typedef
typename
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
typedef
typename
graph_traits
<
Graph
>::
vertex_iterator
vertex_iterator
;
typedef
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex_descriptor
;
typedef
square_topology
<>
Topology
;
typedef
typename
Topology
::
point_type
Point
;
/* structs */
struct
simple_edge
{
int
first
,
second
;
};
/* constants */
namespace
{
/* file io */
const
char
*
PAPER_FILENAME
=
"dblp-paper.txt"
;
...
...
@@ -65,10 +98,11 @@ namespace {
const
int
READ_LINE_UNIT
=
100
;
//한 번에 몇 라인을 읽을지
/* topK */
const
int
topK
=
10
;
//상위 몇 개 아이템에 대해
const
int
TOP_K
=
10
;
//상위 몇 개 아이템에 대해 할 지
}
namespace
boost
{
const
boost
::
regex
paper_reg
(
"(conf|journals).*"
);
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment