조성현

person you might know --> test version

......@@ -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[*vi] == NODE_TYPE::NODE_PAPER) {
if (nodeType[*ai] == 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
......
......@@ -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();
......
......@@ -17,7 +17,7 @@ MainWindow::MainWindow(QWidget *parent)
statusBar()->showMessage(message);
setMinimumSize(160, 160);
resize(800, 600);
resize(1200, 650);
}
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(testHighlightAct);
actionMenu->addAction(mightKnowAct);
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()
......
......@@ -22,7 +22,7 @@ private:
QMenu *fileMenu;
QAction *readMoreAct;
QMenu *actionMenu;
QAction *testHighlightAct;
QAction *mightKnowAct;
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();
};
......
......@@ -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();
}
......
......@@ -16,7 +16,7 @@ public:
//main window slots
void read_more();
void path_highlight();
void might_know();
void topk();
void reset_color();
......
......@@ -105,12 +105,14 @@ namespace {
/* visualization */
const int NODE_SIZE = 4;
const int LAYOUT_MODE = GRAPH_LAYOUT::RANDOM_LAYOUT;
const int SCREEN_SIZE = 1000;
const int READ_LINE_UNIT = 5; //한 번에 몇 라인을 읽을지
const int SCREEN_SIZE = 500;
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 */
......