Ejemplo n.º 1
0
        /// <summary> Returns a shallow copy of this graph instance.  Neither edges nor
        /// vertices are cloned.
        ///
        /// </summary>
        /// <returns> a shallow copy of this set.
        ///
        /// </returns>
        /// <throws>  RuntimeException </throws>
        /// <summary>
        /// </summary>
        /// <seealso cref="java.lang.Object.clone()">
        /// </seealso>
        public virtual System.Object Clone()
        {
            try
            {
                AbstractBaseGraph newGraph = (AbstractBaseGraph)this.MemberwiseClone();

                newGraph.m_vertexMap             = new SupportClass.HashSetSupport();
                newGraph.m_edgeSet               = new SupportClass.HashSetSupport();
                newGraph.m_factoryEdgeClass      = this.m_factoryEdgeClass;
                newGraph.m_edgeFactory           = this.m_edgeFactory;
                newGraph.m_unmodifiableEdgeSet   = null;
                newGraph.m_unmodifiableVertexSet = null;

                // NOTE:  it's important for this to happen in an object
                // method so that the new inner class instance gets associated with
                // the right outer class instance
                newGraph.m_specifics = newGraph.createSpecifics();

                GraphHelper.addGraph(newGraph, this);

                return(newGraph);
            }
            //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
                throw new System.SystemException();
            }
        }
Ejemplo n.º 2
0
        /// <summary> Computes a {@link List} of {@link Set}s, where each set contains
        /// vertices which together form a strongly connected component within the
        /// given graph.
        ///
        /// </summary>
        /// <returns> <code>List</code> of <code>Set</code>s containing the strongly
        /// connected components
        /// </returns>
        public virtual System.Collections.IList stronglyConnectedSets()
        {
            if (m_stronglyConnectedSets == null)
            {
                //UPGRADE_TODO: Class 'java.util.LinkedList' was converted to 'System.Collections.ArrayList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilLinkedList'"
                m_orderedVertices       = new System.Collections.ArrayList();
                m_stronglyConnectedSets = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));

                // create VertexData objects for all vertices, store them
                createVertexData();

                // perform the first round of DFS, result is an ordering
                // of the vertices by decreasing finishing time
                System.Collections.IEnumerator iter = m_vertexToVertexData.Values.GetEnumerator();

                //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                while (iter.MoveNext())
                {
                    //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                    VertexData data = (VertexData)iter.Current;

                    if (!data.m_discovered)
                    {
                        dfsVisit(m_graph, data, null);
                    }
                }

                // calculate inverse graph (i.e. every edge is reversed)
                DirectedGraph inverseGraph = new DefaultDirectedGraph();
                GraphHelper.addGraphReversed(inverseGraph, m_graph);

                // get ready for next dfs round
                resetVertexData();

                // second dfs round: vertices are considered in decreasing
                // finishing time order; every tree found is a strongly
                // connected set
                iter = m_orderedVertices.GetEnumerator();

                //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                while (iter.MoveNext())
                {
                    //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                    VertexData data = (VertexData)iter.Current;

                    if (!data.m_discovered)
                    {
                        // new strongly connected set
                        //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
                        SupportClass.SetSupport set_Renamed = new SupportClass.HashSetSupport();
                        m_stronglyConnectedSets.Add(set_Renamed);
                        dfsVisit(inverseGraph, data, set_Renamed);
                    }
                }

                // clean up for garbage collection
                m_orderedVertices    = null;
                m_vertexToVertexData = null;
            }

            return(m_stronglyConnectedSets);
        }