I'm looking for a directed weighted graph simplification algorithm that seeks chains of nodes which have exactly one inbound edge and exactly one outbound edge and are interconnected and replaces such chains with single node that has weight equal to sum of weights of replaced nodes.
This way, something like that:
w=1 → w=3 → w=2 → (w=7 → w=1 → w=1)
↓ ↑
(w=4 → w=1 → w=2)
becomes:
w=1 → w=3 → w=2 → w=9
↓ ↑
\--> w=7 ---/
Replaced chains of nodes are in brackets ()
on first figure. Obviously, it's very simple to write naive implementation.
What is the name of this algorithm? I want to know to name it properly in discussions, look up in reference books, search for implementations in graph libraries, compare different implementations' performance, etc.