我有一个有向图说,例如fromNode-> toNode。我想计算“ toNode”上的总传入连接,包括1跳或2跳连接。
例如:如果存在节点Z使得X连接Z且Z连接Y的情况,则从节点X到节点Y有两跳连接。
我认为您可以两次使用aggregateMessages()。第一步,收集每个节点的inDegrees并将其存储。在第二步中,将节点中的inDegrees信息收集到最终节点。或者,您可以先使用externalJoinVertices(),例如:
yourGraph = followerGraph.outerJoinVertices(
yourGraph.ops().inDegrees(),
new setDegreesMsg()//use the function to combine inDegrees info with yourGraph
);
然后,使用aggregateMessages()收集邻居中的inDegrees信息,例如:
degrees:RDD[(VertexId, Int)] = yourGraph.aggregateMessages(
new getInfoSendMsg(),
new getInfoMergeMsg()
);