Your observation about the nature of DFS on undirected graphs is correct. In an undirected graph, when performing DFS, if a node is visited again, it must be an ancestor of the current node and not yet finished processing. This is because the graph is undirected, meaning reachability is mutual, and the DFS traversal ensures that ancestors are still on the call stack when their descendants are visited.
However, this insight does not directly help in reducing the number of arrays needed for finding bridges. The two arrays, dfn (or disc) and low, serve distinct purposes:
- dfn (or disc): Stores the discovery time of each vertex, which helps in identifying the order of visitation.
- low: Stores the lowest discovery time reachable from each vertex, which is crucial for detecting bridges by checking if there are back edges connecting a node to its ancestors.
While your observation simplifies the handling of visited nodes (since they must be ancestors), it does not eliminate the need for both arrays. The low array is necessary to track the lowest reachable discovery time, which cannot be inferred solely from the discovery time (dfn).
Simplification in Handling Visited Nodes
Your observation does simplify the handling of visited nodes during DFS. When a visited node is encountered, it is known to be an ancestor and not yet finished processing. However, this does not reduce the need for separate arrays to track discovery times and lowest reachable times.
Conclusion
While your insight into the nature of DFS on undirected graphs is valuable for understanding the traversal process, it does not allow for the elimination of one of the arrays (dfn or low) in the context of finding bridges. Both arrays are necessary for correctly identifying bridges using Tarjan's algorithm or similar approaches[1][2][3][7].