-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph.cpp
More file actions
65 lines (52 loc) · 1.54 KB
/
graph.cpp
File metadata and controls
65 lines (52 loc) · 1.54 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
#include"graph.h"
#define MYU 2
#define UNCLASSIFIED 0
GRAPH::GRAPH(char *infilename)
{
ifstream infile(infilename,ios_base::in | ios_base::binary);
infile.read((char*)&nodemax, 4);
infile.read((char*)&edgemax, 4);
label = new unsigned int[nodemax];
node = new unsigned int[nodemax+1];
edge = new unsigned int[edgemax];
similarity = new unsigned int[edgemax];
sd = new unsigned int[nodemax];
ed = new unsigned int[nodemax];
edgef = new unsigned int[edgemax];
cluset = new unsigned int[nodemax*(MYU-1)];
included_cluster = new unsigned int[nodemax];
infile.read((char*)&node[0],sizeof(unsigned int)*(nodemax+1));
unsigned int q = 0;
for(unsigned int i = 0;i<nodemax;i++){
label[i] = UNCLASSIFIED;
sd[i] = 0;
ed[i] = node[i+1]-node[i];
included_cluster[i] = 0;
for(unsigned int n=0;n<MYU-1;n++)cluset[(MYU-1)*i + n] = -1;
for(unsigned int n=node[i];n<node[i+1];n++){
edgef[q]=i;
q++;
}
}
infile.read((char*)&edge[0],sizeof(unsigned int)*edgemax);
for(unsigned int i = 0;i <edgemax;i++){
similarity[i] = UNCLASSIFIED;
}
}
void GRAPH::power_low_output()
{
ofstream of("power_low.txt",ios::app);
unsigned int maxdegree = 0;
unsigned int *degree;
degree = new unsigned int[nodemax];
for(unsigned int i=0;i<nodemax;i++){
degree[i]=0;
}
for(unsigned int i=0;i<nodemax;i++){
degree[node[i+1]-node[i]] += 1;
if(maxdegree < node[i+1]-node[i])maxdegree = node[i+1]-node[i];
}
for(unsigned int i=0;i<=maxdegree;i++){
of << degree[i] << endl;
}
}