Skip to content

Commit e731266

Browse files
committed
Rename variables to improve readability
1 parent 590fe70 commit e731266

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

core/src/main/java/org/neo4j/graphalgo/core/huge/HugeGraphIntersectImpl.java

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,83 +56,85 @@ class HugeGraphIntersectImpl implements RelationshipIntersect {
5656
}
5757

5858
@Override
59-
public void intersectAll(long nodeIdA, IntersectionConsumer consumer) {
59+
public void intersectAll(long nodeA, IntersectionConsumer consumer) {
6060
// check the first node's degree
61-
if (!degreeFilter.test(nodeIdA)) {
61+
if (!degreeFilter.test(nodeA)) {
6262
return;
6363
}
6464

6565
AdjacencyOffsets offsets = this.offsets;
6666
AdjacencyList adjacency = this.adjacency;
67+
AdjacencyList.DecompressingCursor neighboursAMain = cursor(nodeA, cache, offsets, adjacency);
6768

68-
AdjacencyList.DecompressingCursor mainDecompressingCursor = cursor(nodeIdA, cache, offsets, adjacency);
69-
70-
// find first neighbour B of A id > A
71-
long nodeIdB = mainDecompressingCursor.skipUntil(nodeIdA);
72-
if (nodeIdA > nodeIdB) {
69+
// find first neighbour B of A with id > A
70+
long nodeB = neighboursAMain.skipUntil(nodeA);
71+
// if there is no such neighbour -> no triangle (or we already found it)
72+
if (nodeA > nodeB) {
7373
return;
7474
}
7575

76-
AdjacencyList.DecompressingCursor decompressingCursorA = cacheA, decompressingCursorB = cacheB;
76+
AdjacencyList.DecompressingCursor neighboursA = cacheA, neighboursB = cacheB;
7777

78-
long CfromA;
79-
long CfromB;
78+
long nodeCa;
79+
long nodeCb;
8080
long lastNodeB;
8181
long lastNodeC;
8282

8383
// for all neighbours of A
84-
while (mainDecompressingCursor.hasNextVLong()) {
84+
while (neighboursAMain.hasNextVLong()) {
8585
lastNodeC = -1;
8686
// check the second node's degree
87-
if (degreeFilter.test(nodeIdB)) {
88-
decompressingCursorB = cursor(nodeIdB, decompressingCursorB, offsets, adjacency);
87+
if (degreeFilter.test(nodeB)) {
88+
neighboursB = cursor(nodeB, neighboursB, offsets, adjacency);
8989
// find first neighbour Cb of B with id > B
90-
CfromB = decompressingCursorB.skipUntil(nodeIdB);// check the third node's degree
91-
if (CfromB > nodeIdB && degreeFilter.test(CfromB)) {
90+
nodeCb = neighboursB.skipUntil(nodeB);
91+
92+
// check the third node's degree
93+
if (nodeCb > nodeB && degreeFilter.test(nodeCb)) {
9294
// copy the state of A's cursor
93-
decompressingCursorA.copyFrom(mainDecompressingCursor);
95+
neighboursA.copyFrom(neighboursAMain);
9496
// find the first neighbour Ca of A with id >= Cb
95-
CfromA = decompressingCursorA.advance(CfromB);
97+
nodeCa = neighboursA.advance(nodeCb);
9698

9799
// if Ca = Cb we have found a triangle
98100
// we only submit one triangle per parallel relationship
99-
if (CfromA == CfromB && CfromB > lastNodeC) {
100-
consumer.accept(nodeIdA, nodeIdB, CfromB);
101-
lastNodeC = CfromB;
101+
if (nodeCa == nodeCb && nodeCb > lastNodeC) {
102+
consumer.accept(nodeA, nodeB, nodeCb);
103+
lastNodeC = nodeCb;
102104
}
103105

104106
// while both A and B have more neighbours
105-
while (decompressingCursorB.hasNextVLong() && decompressingCursorA.hasNextVLong()) {
107+
while (neighboursB.hasNextVLong() && neighboursA.hasNextVLong()) {
106108
// take the next neighbour Cb of B
107-
CfromB = decompressingCursorB.nextVLong();
108-
if (CfromB > CfromA) {
109+
nodeCb = neighboursB.nextVLong();
110+
if (nodeCb > nodeCa) {
109111
// if Cb > Ca, take the next neighbour Ca of A with id >= Cb
110-
CfromA = decompressingCursorA.advance(CfromB);
112+
nodeCa = neighboursA.advance(nodeCb);
111113
}
112114
// check for triangle
113-
if (CfromA == CfromB && CfromA > lastNodeC && degreeFilter.test(CfromB)) {
114-
consumer.accept(nodeIdA, nodeIdB, CfromB);
115-
lastNodeC = CfromB;
115+
if (nodeCa == nodeCb && nodeCa > lastNodeC && degreeFilter.test(nodeCb)) {
116+
consumer.accept(nodeA, nodeB, nodeCb);
117+
lastNodeC = nodeCb;
116118
}
117119
}
118120

119121
// it is possible that the last Ca > Cb, but there are no more neighbours Ca of A
120122
// so if there are more neighbours Cb of B
121-
if (decompressingCursorB.hasNextVLong()) {
123+
if (neighboursB.hasNextVLong()) {
122124
// we take the next neighbour Cb of B with id >= Ca
123-
CfromB = decompressingCursorB.advance(CfromA);
125+
nodeCb = neighboursB.advance(nodeCa);
124126
// check for triangle
125-
if (CfromA == CfromB && CfromA > lastNodeC && degreeFilter.test(CfromB)) {
126-
consumer.accept(nodeIdA, nodeIdB, CfromB);
127+
if (nodeCa == nodeCb && nodeCa > lastNodeC && degreeFilter.test(nodeCb)) {
128+
consumer.accept(nodeA, nodeB, nodeCb);
127129
}
128130
}
129131
}
130132
}
131133

132134
// TODO: use skipUntil?
133-
lastNodeB = nodeIdB;
134-
while (mainDecompressingCursor.hasNextVLong() && nodeIdB == lastNodeB) {
135-
nodeIdB = mainDecompressingCursor.nextVLong();
135+
lastNodeB = nodeB;
136+
while (neighboursAMain.hasNextVLong() && nodeB == lastNodeB) {
137+
nodeB = neighboursAMain.nextVLong();
136138
}
137139
}
138140
}

0 commit comments

Comments
 (0)