forked from SNUCSE-CTA/graph-analysis-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.cpp
More file actions
214 lines (195 loc) · 8.08 KB
/
html.cpp
File metadata and controls
214 lines (195 loc) · 8.08 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "html.h"
namespace snu {
void makeDSHtml(const char *name, StatResult& result, Plot& plot)
{
std::string real_name = name + std::string(".html");
FILE *fp = fopen(real_name.c_str(), "w");
fprintf(fp, "\
<!DOCTYPE html>\
<html>\
<head>\
<meta charset = \"utf-8\">\
<title>SNU Graph Analysis Tool</title>\
<style type=\"text/css\">\
h1{\
text-indent: 1em;\
}\
h2{\
text-indent: 2em;\
}\
h3{\
text-indent: 4em;\
}\
</style>\
</head>\
<body>\
<h1><p>SNU Graph Analysis Tool</p></h1>");
fprintf(fp, "\
<h2>\
Graph Information\
</h2>\
<h3>\
<p> graph name: %s </p>\
<p> graph type: directed simple graph </p>\
</h3>\
", name);
//if (result) {
if (result.basicstat)
fprintf(fp, "\
<h2>\
Basic Statistics\
</h2>\
<h3>\
<p> size = %lld </p>\
<p> volume = %lld </p>\
<p> number of vertex labels = %lld </p>\
<p> number of edge labels = %lld </p>\
<p> density = %lf </p>\
<p> maximum indegree = %lld </p>\
<p> maximum outdegree = %lld </p>\
<p> maximum size of vertex label = %lld </p>\
<p> maximum size of edge label = %lld </p>\
<p> reciprocity = %lf </p>\
<p> negativity = %lf </p>\
</h3>\
", result.size, result.volume, result.num_vlabel, result.num_elabel
, result.density, result.max_indegree, result.max_outdegree
, result.max_vlabel_size, result.max_elabel_size, result.reciprocity
, result.negativity);
if (result.connectstat)
fprintf(fp, "\
<h2>\
Connectivity Statistics\
</h2>\
<h3>\
<p> number of strongly connected components = %lld </p>\
<p> size of largest strongly connected component = %lld </p>\
<p> number of weakly connected components = %lld </p>\
<p> size of largest weakly connected component = %lld </p>\
</h3>\
", result.num_scc, result.size_lscc, result.num_wcc, result.size_lwcc);
//}
if (plot.makeplot)
fprintf(fp, "\
<h2>\
Statistics Image\
</h2>\
<h3>\
<p> label-vertex image </p>\
<img src=\"pyplot/%s_label-vertex.png\" width=\"400\" alt=\"label-vertex image\">\
<img src=\"pyplot/%s_label-vertex_log.png\" width=\"400\" alt=\"log scale label-vertex image\">\
</h3>\
<h3>\
<p> indegree image </p>\
<img src=\"pyplot/%s_indegree.png\" width=\"400\" alt=\"indegree image\">\
<img src=\"pyplot/%s_indegree_log.png\" width=\"400\" alt=\"log scale indegree image\">\
</h3>\
<h3>\
<p> outdegree image </p>\
<img src=\"pyplot/%s_outdegree.png\" width=\"400\" alt=\"outdegree image\">\
<img src=\"pyplot/%s_outdegree_log.png\" width=\"400\" alt=\"log scale outdegree image\">\
</h3>\
", plot.name.c_str(), plot.name.c_str(), plot.name.c_str(), plot.name.c_str(), plot.name.c_str(), plot.name.c_str());
fprintf(fp, "</body></html>");
fclose(fp);
}
void makeUSHtml(const char *name, StatResult& result, Plot& plot)
{
std::string real_name = name + std::string(".html");
FILE *fp = fopen(real_name.c_str(), "w");
fprintf(fp, "\
<!DOCTYPE html>\
<html>\
<head>\
<meta charset = \"utf-8\">\
<title>SNU Graph Analysis Tool</title>\
<style type=\"text/css\">\
h1{\
text-indent: 1em;\
}\
h2{\
text-indent: 2em;\
}\
h3{\
text-indent: 4em;\
}\
</style>\
</head>\
<body>\
<h1><p>SNU Graph Analysis Tool</p></h1>");
fprintf(fp, "\
<h2>\
Graph Information\
</h2>\
<h3>\
<p> graph name: %s </p>\
<p> graph type: undirected simple graph </p>\
</h3>\
", name);
//if (result) {
if(result.basicstat)
fprintf(fp, "\
<h2>\
Basic Statistics\
</h2>\
<h3>\
<p> size = %lld </p>\
<p> volume = %lld </p>\
<p> number of vertex labels = %lld </p>\
<p> number of edge labels = %lld </p>\
<p> density = %lf </p>\
<p> average degree = %lf </p>\
<p> maximum degree = %lld </p>\
<p> maximum size of vertex label = %lld </p>\
<p> maximum size of edge label = %lld </p>\
<p> negativity = %lf </p>\
</h3>\
", result.size, result.volume, result.num_vlabel, result.num_elabel
, result.density, result.avg_degree, result.max_degree
, result.max_vlabel_size, result.max_elabel_size, result.negativity);
if (result.connectstat)
fprintf(fp, "\
<h2>\
Connectivity Statistics\
</h2>\
<h3>\
<p> number of connected components = %lld </p>\
<p> size of largest connected component = %lld </p>\
<p> approximate diameter (largest distance of all shortest path) = %lld </p>\
</h3>\
", result.num_cc, result.size_lcc, result.diameter);
if (result.countstat)
fprintf(fp, "\
<h2>\
Count statistics\
</h2>\
<h3>\
<p> number of wedges = %llu </p>\
<p> number of claws = %llu </p>\
<p> number of triangles = %llu </p>\
</h3>\
", result.wedge_count, result.claw_count, result.triangle_count);
//}
if (plot.makeplot)
fprintf(fp, "\
<h2>\
Statistics Image\
</h2>\
<h3>\
<p> label-vertex image </p>\
<img src=\"pyplot/%s_label-vertex.png\" width=\"400\" alt=\"label-vertex image\">\
<img src=\"pyplot/%s_label-vertex_log.png\" width=\"400\" alt=\"log scale label-vertex image\">\
</h3>\
<h3>\
<p> degree image </p>\
<img src=\"pyplot/%s_degree.png\" width=\"400\" alt=\"degree image\">\
<img src=\"pyplot/%s_degree_log.png\" width=\"400\" alt=\"log scale degree image\">\
</h3>\
", plot.name.c_str(), plot.name.c_str(), plot.name.c_str(), plot.name.c_str());
fprintf(fp, "</body></html>");
fclose(fp);
}
}