Would the following graph algorithm be possible to implement with Spark GraphFrames?
Given a graph, I'd like to remove nodes that have exactly one incoming edge and one outgoing edge, and merge the two edges into one edge. For instance, assume the we have:
then the graph simplification algorithm would remove the two nodes in the middle (and merge the edges and add up the weights of 1, 8, 3 into 12). And similarly for top-right portion merge the two edges into one (and add up edge weights 2 and 1 into 3)
I found a similar solution using networkx here: Remove all nodes in a networkx DiGraph with in-degree and out-degree equal to 1
But I can't use networkx as my graph is very large, so I'd like to see if it is possible to implement this with Spark GraphFrames