in graphjet-core/src/main/java/com/twitter/graphjet/algorithms/counting/TopSecondDegreeByCount.java [101:151]
protected abstract boolean isEdgeUpdateValid(
Request request,
long rightNode,
byte edgeType,
long edgeMetadata
);
/**
* Update node information gathered about each RHS node, such as metadata and weights.
* This method update nodes in {@link TopSecondDegreeByCount#visitedRightNodes}.
* @param leftNode is the LHS node from which traversal initialized
* @param rightNode is the RHS node at which traversal arrived
* @param edgeType is the edge type from which LHS and RHS nodes are connected
* @param edgeMetadata is the edge metadata from which LHS and RHS nodes are connected
* @param weight is the weight contributed to a RHS node in this traversal
* @param edgeIterator is the iterator for traversing edges from LHS node
*/
protected abstract void updateNodeInfo(
long leftNode,
long rightNode,
byte edgeType,
long edgeMetadata,
double weight,
EdgeIterator edgeIterator,
int maxSocialProofTypeSize);
/**
* Generate and return recommendation response. As the last step in the calculation,
* this method should utilize filtered information gathered in
* {@link TopSecondDegreeByCount#nodeInfosAfterFiltering}.
* @param request is the original request object
* @return is the recommendations
*/
protected abstract Response generateRecommendationFromNodeInfo(Request request);
/**
* Compute recommendations using the TopSecondDegreeByCount algorithm.
* @param request is the request for the algorithm
* @param random is used for all random choices within the algorithm
* @return Right hand side nodes with largest weights
*/
@Override
public Response computeRecommendations(Request request, Random random) {
numRequestsCounter.incr();
reset(request);
collectRightNodeInfo(request);
updateAlgorithmStats(request.getQueryNode());
filterNodeInfo(request);
return generateRecommendationFromNodeInfo(request);
}