Here is my code where the problem happens, I’ve bolded line 90 (where the error message says the problem is originating) [edit: I can’t figure out how to bold inside a code block, I marked it with an arrow instead]:
while ((l<=list_L.size())&&(i<=list_I.size())) {
if (list_I.get(i).url.compareTo(list_L.get(l).src) == 0) { //<--- LINE 90
int firstmatch = l;
int outgoing = 1;
l++;
while (list_I.get(i).url.compareTo(list_L.get(l).src) == 0) {
outgoing++;
l++;
}
l = firstmatch;
for (int k=0; k<outgoing; k++) {
list_R.add(new Triplet(list_L.get(l).src, list_L.get(l).dest, list_I.get(i).rank / outgoing));
l++;
}
}
else {
sum_T += list_I.get(i).rank; //This shouldn't happen in this case...
}
i++;
}
And here is the error message:
Exception in thread “main” java.lang.IndexOutOfBoundsException: Index:
118981, Size: 118981
at java.util.ArrayList.RangeCheck(Unknown
Source)
at java.util.ArrayList.get(Unknown Source)
at
PageRank.main(PageRank.java:90)
I don’t know what is going wrong since it isn’t a nullpointer exception like I would expect if something WAS wrong…
UPDATE:
Ok I fixed the problem in the initial location but now it’s happening here:
for (int p=0; p<list_I2.size(); p++) {
L2_norm += Math.pow((list_I.get(p).rank - list_I2.get(p).rank), 2); // <-- LINE 146
}
Error Message:
Exception in thread “main” java.lang.IndexOutOfBoundsException: Index:
118981, Size: 118981
at java.util.ArrayList.RangeCheck(Unknown
Source)
at java.util.ArrayList.get(Unknown Source)
at
PageRank.main(PageRank.java:146)
list_I and list_I2 are the same size and I have confirmed so in debugging.
the condition should be :
not
If a list has a size of X, the last index of the list is X-1.