-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSumgra.cpp
78 lines (71 loc) · 2.67 KB
/
Sumgra.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (c) 2015 Vijay Ingalalli
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "include/FileManager.h"
#include "include/IndexManager.h"
#include "include/SubgraphMatcher.h"
int main(int argc, char* argv[])
{
std::string dataPath = argv[1];
std::string queryPath = argv[2];
std::string resultPath = argv[3];
std::string nQueries = argv[4];
std::string printEmb = argv[5];
/// Read data graph
cout << "Reading data files..." << endl;
std::string nodeFile = dataPath + "nodes.txt";
std::string edgeFile = dataPath + "edges.txt";
GraphParameter dataGraph;
FileManager dataGraphInfo;
dataGraphInfo.readContents(nodeFile, edgeFile, dataGraph);
/// Build data graph indexes
cout << "Building indexes..." << endl;
IndexManager graphDB;
IndexType graphIndexes;
TimeEval timeEval;
clock_t start = clock();
graphDB.buildIndexes(dataGraph, graphIndexes);
timeEval.buildIndex = double(clock()- start)/CLOCKS_PER_SEC;
/// Query processing
int qN = std::stoi(nQueries), i = 0;
std::string timeFile = resultPath + "time.txt";
FileManager writeFile;
writeFile.createNew(timeFile);
cout << "Reading query files..." << endl;
while(i < qN){
/// Read query graph
std::string nodeFile = queryPath + std::to_string(i) + "_nodes.txt";
std::string edgeFile = queryPath + std::to_string(i) + "_edges.txt";
GraphParameter queryGraph;
FileManager queryGraphInfo;
queryGraphInfo.readContents(nodeFile, edgeFile, queryGraph);
/// Perfrom subgraph matching
SubgraphMatcher subGraph;
start = clock();
subGraph.findEmbeddings(queryGraph, graphIndexes);
timeEval.queryMatch = double(clock()- start)/CLOCKS_PER_SEC;
cout << i << ": " << queryGraph.embeddings.size() << " embeddings found" << endl;
//cout << "Time: " << timeEval.queryMatch << endl;
/// Collect results
writeFile.printTime(timeEval, timeFile, queryGraph, i); // #embeddings, query time consumption
if(printEmb == "yes"){ // Print embeddings
std::string embFile = resultPath + std::to_string(i) + "_emb.txt";
writeFile.printEmbeddings(queryGraph, dataGraph.inNodes, embFile);
}
++i;
}
return 0;
}