7

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.

  • 1
    In general, this is referred to as [Edge contraction](https://en.wikipedia.org/wiki/Edge_contraction), but I guess this still misses the crucial point: This does **not** only apply to "paths". Maybe a starting point, though... – Marco13 Jul 12 '16 at 16:31
  • 1
    Another term that isn't quite right is [path compression](https://courses.cs.washington.edu/courses/cse326/00wi/handouts/lecture18/sld035.htm), used for speeding up disjoint set algorithms. – j_random_hacker Jul 12 '16 at 16:53
  • 1
    @Marco13 "Edge contraction" is a much more generic term, it's basically an operation of removal of an edge while keeping some of the properties of the graph intact. – Emil Çiçek Jul 12 '16 at 17:54
  • 1
    There is no 'standard' name for this graph operation. – Lior Kogan Jul 12 '16 at 18:36
  • I just mentioned edge contraction beause, IF there is no "standard term" (which remains to be proven), then one could simply refer to it as "contraction of edges whose vertices all have degree 2", and/or simply coin/define the term "path contraction" for this operation. – Marco13 Jul 13 '16 at 09:25
  • Did anyone find out the name of this algorithm? If not, does anyone have the implementation? – Raphael Sampaio Jan 06 '20 at 18:48
  • Looks like vertex smoothing https://en.wikipedia.org/wiki/Homeomorphism_(graph_theory)#Subdivision_and_smoothing – Denis Apr 06 '21 at 17:52

0 Answers0