forked from CGCL-codes/DGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis.cpp
More file actions
66 lines (55 loc) · 1.38 KB
/
analysis.cpp
File metadata and controls
66 lines (55 loc) · 1.38 KB
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
/*
* Generate scc data: scc id, vtxs in scc, scc in, scc out
*/
#include "gfile.h"
#include <string>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <string>
int main(int argc, char *argv[])
{
if (argc != 4)
{
cout << "Usage ./analysis <data dir> <to dir> <name>" << endl;
return 0;
}
string dir(argv[1]), to_dir(argv[2]), name(argv[3]), name_dir(to_dir + string("/") + name);
RawFile<ID> scc_group("scc_group.bin", dir);
scc_group.open();
VtxsFile<ID> scc_vtxs("scc_vtx.bin", "scc_vindex.bin", dir);
scc_vtxs.open();
FILE *fp;
fp = fopen(name_dir.c_str(), "w+");
fprintf(fp, "digraph G{\n" );
string agm(
string("graph[overlap = scale, rankdir = LR];\n") +
string("node[shape = point, color = red];\n")
+ string("edge[arrowsize = 0.1, penwidth = 0.1, color = gray];\n")
);
fprintf(fp, "%s", agm.c_str());
stringstream ss;
for(ID i = 0; i < scc_vtxs.size(); i++)
{
ss << i;
addr_t base = scc_vtxs.get_vtx_base_addr(i);
if(base == NULL)
ss << ";\n";
else
{
ss << "->{";
ID *outbor = VtxUnitIdData::bor(base);
bor_cnt_t size = VtxUnitIdData::bor_cnt(base);
for(ID j = 0; j < size; j++)
ss << outbor[j] << ";";
ss << "};\n";
}
fprintf(fp, "%s", ss.str().c_str());
ss.str("");
}
fprintf(fp, "}\n");
fclose(fp);
scc_group.close();
scc_vtxs.close();
return 0;
}