I have a directed cyclic graph with values at edges but no values at nodes.
The graph has a start node and an end node, and I want to preserve the set of paths through the graph but I don't care about the nodes on the path, only the edge values. Example below.
Are there any algorithms that will produce a smaller graph that preserves that property?
The graph might have 10's of thousands of nodes, but not millions. The number of edges per node is small w.r.t. the number of nodes.
Conservative heuristics are welcome.
As an example, where O
is a node, and a number is the value of the adjacent edge:
O --------> O -------> O
2 3
^ |4
|1 v
1 2 3 4
start -> O -> O -> O -> end
|5 ^
v |8
O --------> O -------> O
6 7
has two paths with edge values [1,2,3,4] from start to end, so one is redundant, and I would be happy to reduce the above to
O --------> O -------> O
2 3
^ |4
|1 v
start end
|5 ^
v |8
O --------> O -------> O
6 7
The graph can be cyclic, so in
1
/-\
| /
v/
start -> O -> O -> end
1 1 2
a simpler graph would eliminate the second 1 transition to leave only the self-edge:
1
/-\
| /
v/
start -> O -> end
1 2
Implication Charts did what I need. They're O(n**2) space-wise on the number of nodes, but that's manageable in my situation.