General framework and sankey implementation