graphx
graphx copied to clipboard
Edge contraction
Based on our discussion today it seems like it might be helpful to have a function of the form:
def contractEdges(
ePred: EdgeTriplet[VD,ED] => Boolean,
contractFun: EdgeTriplet[VD,ED] => VD,
mergeFun: (VD, VD) => VD): Graph[VD, ED]
where the user defined edge predicate ePred determines which edges to contract and the user defined contractFun renders a new vertex for the contracted edge and mergeFun merges multiple vertices that have been contracted together.
This function is actually pretty challenging given that an invocation of:
g.contractEdges(x => true, _.srcAttr, (a,b) => a)
computes connected components.