in graphjet-core/src/main/java/com/twitter/graphjet/algorithms/salsa/subgraph/SalsaSubgraphInternalState.java [128:175]
public void constructSubgraphAndTraverseOnce(
SalsaNodeVisitor.NodeVisitor nodeVisitor,
Random random) {
for (Long2IntMap.Entry entry : currentLeftNodes.long2IntEntrySet()) {
long leftNode = entry.getLongKey();
int numWalks = entry.getIntValue();
EdgeIterator sampledRightNodes =
leftIndexedBipartiteGraph.getRandomLeftNodeEdges(leftNode, numWalks, random);
int degree = 0;
if (sampledRightNodes != null) {
subgraphLeftNodes[numLeftNodesAdded] = leftNode;
while (sampledRightNodes.hasNext()) {
long rightNode = sampledRightNodes.nextLong();
subgraphEdgesArray[numEdgesAdded] = rightNode;
subgraphEdgeMetadataArray[numEdgesAdded] = sampledRightNodes.currentMetadata();
subgraphEdgeTypesArray[numEdgesAdded] = sampledRightNodes.currentEdgeType();
numEdgesAdded++;
subgraphRightNodeDegreeReciprocal.put(
rightNode, subgraphRightNodeDegreeReciprocal.get(rightNode) + 1);
int numVisits = visitRightNode(
nodeVisitor,
leftNode,
rightNode,
sampledRightNodes.currentEdgeType(),
sampledRightNodes.currentMetadata(),
1.0
);
salsaStats.updateVisitStatsPerRightNode(numVisits);
degree++;
}
subgraphLeftNodeDegree[numLeftNodesAdded++] = degree;
}
}
// compute degree inverse
for (long entry : subgraphRightNodeDegreeReciprocal.keySet()) {
subgraphRightNodeDegreeReciprocal.put(
entry, 1.0 / subgraphRightNodeDegreeReciprocal.get(entry));
}
salsaStats.addToNumRHSVisits(numEdgesAdded);
LOG.info("SALSA subgraph iteration initialized"
+ " with numLeftNodes = "
+ currentLeftNodes.size()
+ " numEdgesAdded = "
+ numEdgesAdded
+ " numVisitedRightNodes = "
+ visitedRightNodes.size()
);
}