/// <summary>
        /// Executes the algorithm
        /// </summary>
        /// <returns>The total number of components is the return value of the function</returns>
        public int Compute()
        {
            m_Count = int.MaxValue;
            m_Components.Clear();

            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(VisitedGraph);

            dfs.StartVertex    += new VertexHandler(this.StartVertex);
            dfs.DiscoverVertex += new VertexHandler(this.DiscoverVertex);

            return(m_Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the algorithm
        /// </summary>
        /// <remarks>
        /// The output of the algorithm is recorded in the component property
        /// Components, which will contain numbers giving the component ID
        /// assigned to each vertex.
        /// </remarks>
        /// <returns>The number of components is the return value of the function.</returns>
        public int Compute()
        {
            m_Components.Clear();
            m_Roots.Clear();
            m_DiscoverTimes.Clear();
            m_Count   = 0;
            m_DfsTime = 0;

            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(VisitedGraph);

            dfs.DiscoverVertex += new VertexHandler(this.DiscoverVertex);
            dfs.FinishVertex   += new VertexHandler(this.FinishVertex);

            dfs.Compute();

            return(++m_Count);
        }