Why isn't traversal aborted at a back edge when determining whether a graph is directed acyclic?

Topics: algorithm, graph
Dec 12, 2011 at 7:48 PM

AlgorithmExtensions.cs:

class DagTester<TVertex,TEdge>
                where TEdge : IEdge<TVertex>
        {
            private bool isDag = true;

            public bool IsDag(IVertexListGraph<TVertex, TEdge> g)
            {
                var dfs = new DepthFirstSearchAlgorithm<TVertex, TEdge>(g);
                try
                {
                    dfs.BackEdge += new EdgeAction<TVertex, TEdge>(dfs_BackEdge);
                    isDag = true;
                    dfs.Compute();
                    return isDag;
                }
                finally
                {
                    dfs.BackEdge -= new EdgeAction<TVertex, TEdge>(dfs_BackEdge);
                }
            }

            void dfs_BackEdge(TEdge e)
            {
                isDag = false;
            }
        }

Why isn't dfs.Abort() called when isDag is set to false?  (Obviously, this would require changing the scope of dfs.)