Skip to content

Commit 155a9ee

Browse files
committed
Arrays.useLegacyMergeSort MESSAGE + Simple Test
1 parent aabfea2 commit 155a9ee

File tree

10 files changed

+227
-149
lines changed

10 files changed

+227
-149
lines changed

.gitignore

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,64 @@
1-
# Windows image file caches
2-
Thumbs.db
3-
ehthumbs.db
4-
5-
# Folder config file
6-
Desktop.ini
7-
8-
# Recycle Bin used on file shares
9-
$RECYCLE.BIN/
10-
11-
# Windows Installer files
12-
*.cab
13-
*.msi
14-
*.msm
15-
*.msp
16-
17-
# Windows shortcuts
18-
*.lnk
19-
20-
# =========================
21-
# Operating System Files
22-
# =========================
23-
24-
# OSX
25-
# =========================
26-
27-
.DS_Store
28-
.AppleDouble
29-
.LSOverride
30-
31-
# Thumbnails
32-
._*
33-
34-
# Files that might appear in the root of a volume
35-
.DocumentRevisions-V100
36-
.fseventsd
37-
.Spotlight-V100
38-
.TemporaryItems
39-
.Trashes
40-
.VolumeIcon.icns
41-
42-
# Directories potentially created on remote AFP share
43-
.AppleDB
44-
.AppleDesktop
45-
Network Trash Folder
46-
Temporary Items
47-
.apdisk
48-
49-
# Netbeans
50-
nbproject/private/
51-
build/
52-
nbbuild/
53-
dist/
54-
nbdist/
55-
.nb-gradle/
56-
/bin/
57-
/.settings/
58-
/.classpath
59-
/.project
60-
target/
1+
# Windows image file caches
2+
Thumbs.db
3+
ehthumbs.db
4+
5+
# Folder config file
6+
Desktop.ini
7+
8+
# Recycle Bin used on file shares
9+
$RECYCLE.BIN/
10+
11+
# Windows Installer files
12+
*.cab
13+
*.msi
14+
*.msm
15+
*.msp
16+
17+
# Windows shortcuts
18+
*.lnk
19+
20+
# =========================
21+
# Operating System Files
22+
# =========================
23+
24+
# OSX
25+
# =========================
26+
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Thumbnails
32+
._*
33+
34+
# Files that might appear in the root of a volume
35+
.DocumentRevisions-V100
36+
.fseventsd
37+
.Spotlight-V100
38+
.TemporaryItems
39+
.Trashes
40+
.VolumeIcon.icns
41+
42+
# Directories potentially created on remote AFP share
43+
.AppleDB
44+
.AppleDesktop
45+
Network Trash Folder
46+
Temporary Items
47+
.apdisk
48+
49+
# Netbeans
50+
nbproject/private/
51+
build/
52+
nbbuild/
53+
dist/
54+
nbdist/
55+
.nb-gradle/
56+
/bin/
57+
/.settings/
58+
/.classpath
59+
/.project
60+
target/
61+
/datasets/
62+
/gc.bat
63+
/offset.bat
64+
/pagerank.bat

GraphCompressionByBFS-0.3.3.jar

406 Bytes
Binary file not shown.

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ to remove `WebGraph` from the requirements.
4343

4444
*Note: The original project was compiled under Java 6 so if you need to run it in Java 6 just few (very simple) changes are required*
4545

46+
**IMPORTANT**
47+
48+
**The program was tested under Java 6 but from Java 7 the Java merge algorithm was changed.
49+
This is causing some issue, please use the `java.util.Arrays.useLegacyMergeSort=true` option:**
50+
```
51+
java -Djava.util.Arrays.useLegacyMergeSort=true -Xmx4g -Xms512m [CLASSPATH] it.uniroma3.dia.gc.Main OPTIONS
52+
```
53+
**I will check the error and hopefully fixing it.**
54+
4655
## Installation
4756

4857
Download the jar file, set `WebGraph` into the classpath, and that's it.
@@ -95,12 +104,12 @@ Parsing-Compression phase.
95104
96105
Loading graph... done.
97106
98-
Nodes: 5 Links: 7 Level: 8 Root: 0
107+
Nodes: 5 Links: 7 Level: 1000 Root: 1
99108
100109
BFS Compression: 100% (Links removed: 3) in 0 m 0 s
101110
Writing .map file... done.
102111
103-
Size: 48 bits (6,857 bits/link)
112+
Size: 69 bits (9,857 bits/link)
104113
```
105114

106115
Now you have three more files:
@@ -116,16 +125,16 @@ java it.uniroma3.dia.gc.algorithms.PageRank simple 100 0.2
116125
It works!
117126
```
118127
Loading Graph... done.
119-
Time: 11 ms
128+
Time: 20 ms
120129
Creating PageRank... done.
121-
Time: 1 ms
130+
Time: 0 ms
122131
Computing ranks... done.
123-
Time: 1 ms - Time/Iteration: 0,01 ms
124-
1. Page: 3 Rank: 0,20992
125-
2. Page: 1 Rank: 0,20802
126-
3. Page: 4 Rank: 0,20802
127-
4. Page: 0 Rank: 0,18702
128-
5. Page: 2 Rank: 0,18702
132+
Time: 6 ms - Time/Iteration: 0,06 ms
133+
1. Page: 1 Rank: 0,20992
134+
2. Page: 0 Rank: 0,20802
135+
3. Page: 2 Rank: 0,20802
136+
4. Page: 3 Rank: 0,18702
137+
5. Page: 4 Rank: 0,18702
129138
6. Page: 0 Rank: 0,00000
130139
...
131140
```

javadoc/index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
77
<title>GraphCompressionByBFS 0.3.3 API</title>
88
<script type="text/javascript">
9-
targetPage = "" + window.location.search;
10-
if (targetPage != "" && targetPage != "undefined")
11-
targetPage = targetPage.substring(1);
12-
if (targetPage.indexOf(":") != -1 || (targetPage != "" && !validURL(targetPage)))
13-
targetPage = "undefined";
9+
tmpTargetPage = "" + window.location.search;
10+
if (tmpTargetPage != "" && tmpTargetPage != "undefined")
11+
tmpTargetPage = tmpTargetPage.substring(1);
12+
if (tmpTargetPage.indexOf(":") != -1 || (tmpTargetPage != "" && !validURL(tmpTargetPage)))
13+
tmpTargetPage = "undefined";
14+
targetPage = tmpTargetPage;
1415
function validURL(url) {
1516
try {
1617
url = decodeURIComponent(url);

javadoc/javadoc.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"C:\Program Files\Java\jdk1.8.0_74\jre\..\bin\javadoc.exe" @options @packages
1+
"C:\Program Files\Java\jdk1.8.0_121\jre\..\bin\javadoc.exe" @options @packages

nb-configuration.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<project-shared-configuration>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
33
<!--
44
This file contains additional configuration written by modules in the NetBeans IDE.
55
The configuration is intended to be shared among all the users of project and
66
therefore it is assumed to be part of version control checkout.
77
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8-
-->
9-
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
1010
<!--
1111
Properties that influence various parts of the IDE, especially code formatting and the like.
1212
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
1313
That way multiple projects can share the same settings (useful for formatting rules for example).
1414
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15-
-->
16-
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
17-
</properties>
18-
</project-shared-configuration>
15+
-->
16+
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
17+
<netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
18+
</properties>
19+
</project-shared-configuration>

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@
7373
</filesets>
7474
</configuration>
7575
</plugin>
76+
<plugin>
77+
<artifactId>maven-dependency-plugin</artifactId>
78+
<executions>
79+
<execution>
80+
<phase>process-sources</phase>
81+
<goals>
82+
<goal>copy-dependencies</goal>
83+
</goals>
84+
<configuration>
85+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
86+
</configuration>
87+
</execution>
88+
</executions>
89+
</plugin>
7690
</plugins>
7791
</build>
7892

simple.net

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
0 1 2
3+
1 0
4+
2
5+
3 2 4
6+
4 1 3

src/main/java/it/uniroma3/dia/gc/ASCIIGraph.java

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -56,71 +56,73 @@ public ASCIIGraph(final String fileName) throws Exception {
5656
public ASCIIGraph(final String fileName, final boolean inLinks) throws Exception {
5757
int i,j;
5858
this.graphName=fileName;
59-
BufferedReader reader=new BufferedReader(new FileReader(fileName+".net"));
60-
N=Integer.parseInt(reader.readLine());
61-
if (N<=0) {
62-
reader.close();
63-
throw new ASCIIGraphFormatException("Network dimension "+N+" less than or euqal to 0!");
64-
}
65-
this.indegrees=null;
66-
this.inLinks=inLinks;
67-
long edges=0;
68-
this.nodes=new Node[N];
69-
for (i=0;i<N;i++) {
70-
String s=reader.readLine();
71-
if (s==null) break;
72-
String[] tokens=s.split(" ");
73-
final int degree=tokens.length-1;
74-
int id=Integer.parseInt(tokens[0]);
75-
if (id<0 || id>=N) {
76-
reader.close();
77-
throw new ASCIIGraphFormatException("Node out of bounds: node "+id+
78-
" is greater than or equal to the network dimension "+N+"!");
79-
}
80-
if (this.nodes[id]!=null) {
81-
reader.close();
82-
throw new ASCIIGraphFormatException("Wrong network format: multiple "+id+"-node lines!");
83-
}
84-
Node node=new Node(id,degree);
85-
this.nodes[id]=node;
86-
for (j=1;j<tokens.length;j++) {
87-
edges++;
88-
id=Integer.parseInt(tokens[j]);
89-
if (id<0 || id>=N) {
90-
reader.close();
91-
throw new ASCIIGraphFormatException("Node out of bounds: node "+id+
92-
" is greater than or equal to the network dimension "+N+"!");
93-
}
94-
node.addOutLink(id);
95-
}
96-
}
97-
this.edges = edges;
98-
if (!inLinks) {
99-
for (i=0;i<N;i++) {
100-
if (this.nodes[i]==null) this.nodes[i]=new Node(i,0);
101-
else this.nodes[i].sort();
102-
}
103-
} else {
104-
for (i=0;i<N;i++) {
105-
if (this.nodes[i]==null) {
106-
this.nodes[i]=new Node(i,0);
107-
} else {
108-
final int[] out=nodes[i].getOutLinks();
109-
for (j=0;j<out.length;j++) {
110-
if (nodes[out[j]]==null) nodes[out[j]]=new Node(i,0);
111-
nodes[out[j]].incInDegree();
112-
}
113-
}
114-
}
115-
for (i=0;i<N;i++) {
116-
final int[] out=nodes[i].getOutLinks();
117-
for (j=0;j<out.length;j++)
118-
nodes[out[j]].addInLink(i);
119-
}
120-
for (i=0;i<N;i++)
121-
this.nodes[i].sort();
122-
}
123-
59+
try (FileReader fr = new FileReader(fileName+".net")) {
60+
try (BufferedReader reader=new BufferedReader(fr)) {
61+
N=Integer.parseInt(reader.readLine());
62+
if (N<=0) {
63+
reader.close();
64+
throw new ASCIIGraphFormatException("Network dimension "+N+" less than or euqal to 0!");
65+
}
66+
this.indegrees=null;
67+
this.inLinks=inLinks;
68+
long edges=0;
69+
this.nodes=new Node[N];
70+
for (i=0;i<N;i++) {
71+
String s=reader.readLine();
72+
if (s==null) break;
73+
String[] tokens=s.split(" ");
74+
final int degree=tokens.length-1;
75+
int id=Integer.parseInt(tokens[0]);
76+
if (id<0 || id>=N) {
77+
reader.close();
78+
throw new ASCIIGraphFormatException("Node out of bounds: node "+id+
79+
" is greater than or equal to the network dimension "+N+"!");
80+
}
81+
if (this.nodes[id]!=null) {
82+
reader.close();
83+
throw new ASCIIGraphFormatException("Wrong network format: multiple "+id+"-node lines!");
84+
}
85+
Node node=new Node(id,degree);
86+
this.nodes[id]=node;
87+
for (j=1;j<tokens.length;j++) {
88+
edges++;
89+
id=Integer.parseInt(tokens[j]);
90+
if (id<0 || id>=N) {
91+
reader.close();
92+
throw new ASCIIGraphFormatException("Node out of bounds: node "+id+
93+
" is greater than or equal to the network dimension "+N+"!");
94+
}
95+
node.addOutLink(id);
96+
}
97+
}
98+
this.edges = edges;
99+
if (!inLinks) {
100+
for (i=0;i<N;i++) {
101+
if (this.nodes[i]==null) this.nodes[i]=new Node(i,0);
102+
else this.nodes[i].sort();
103+
}
104+
} else {
105+
for (i=0;i<N;i++) {
106+
if (this.nodes[i]==null) {
107+
this.nodes[i]=new Node(i,0);
108+
} else {
109+
final int[] out=nodes[i].getOutLinks();
110+
for (j=0;j<out.length;j++) {
111+
if (nodes[out[j]]==null) nodes[out[j]]=new Node(i,0);
112+
nodes[out[j]].incInDegree();
113+
}
114+
}
115+
}
116+
for (i=0;i<N;i++) {
117+
final int[] out=nodes[i].getOutLinks();
118+
for (j=0;j<out.length;j++)
119+
nodes[out[j]].addInLink(i);
120+
}
121+
for (i=0;i<N;i++)
122+
this.nodes[i].sort();
123+
}
124+
}
125+
}
124126
}
125127

126128
@Override

0 commit comments

Comments
 (0)