Given a bi-partite graph with node weights for both type A and type B nodes as shown below:
I want to output an ordered list of type B nodes as defined by the following heuristic:
- For each node of type B we sum over node weights of type A that this node has an edge with and multiply the sum with its own node weight to get the node value.
- We then select the node from type B which has the highest value and append it to the output set S.
- We delete the selected node from type B and all the nodes it had an edge to from type A.
- Go back to step 1 until any node in type B is left with an edge to a node in type A.
- Append any remaining node of type B to the output set in order of its node weight.
The figure below shows an example:
For this example, the output set will be: (Y, Z, X)
The naive process will be to simply walk through this algorithm but assuming the bi-partite graph is huge, I am looking for the most efficient way to find the output set. Note, I just need the ordered list of type B nodes as output without the intermediate calculated values (eg. 50, 15, 2)

