조성현

variable arrange

......@@ -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);
......
......@@ -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;
......
......@@ -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
......