cyclic-graph

How to detect if adding an edge to a directed graph results in a cycle?

依然范特西╮ 提交于 2019-11-27 05:37:17
问题 I came upon wait-for graphs and I wonder, are there any efficient algorithms for detecting if adding an edge to a directed graph results in a cycle? The graphs in question are mutable (they can have nodes and edges added or removed). And we're not interested in actually knowing an offending cycle, just knowing there is one is enough (to prevent adding an offending edge). Of course it'd be possible to use an algorithm for computing strongly connected components (such as Tarjan's) to check if