コード例 #1
0
 private void InitBlock(SimpleCycleBasis enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
コード例 #2
0
 public AnonymousClassComparator(SimpleCycleBasis enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
コード例 #3
0
 internal AuxiliaryGraph2(SimpleCycleBasis enclosingInstance, org._3pq.jgrapht.Graph graph, System.Collections.IList edgeList, bool[] ui, bool[] uj)
 {
     InitBlock(enclosingInstance);
     g = graph;
     this.ui = ui;
     this.uj = uj;
 }
コード例 #4
0
 public AuxiliaryGraph(SimpleCycleBasis enclosingInstance, org._3pq.jgrapht.Graph graph, bool[] u)
 {
     InitBlock(enclosingInstance);
     g = graph;
     this.u = u;
 }
コード例 #5
0
ファイル: CycleBasis.cs プロジェクト: xuchuansheng/GenXSource
        /// <summary> Constructs a minimum cycle basis of a graph.
        /// 
        /// </summary>
        /// <param name="g">the graph for the cycle basis
        /// </param>
        public CycleBasis(UndirectedGraph g)
        {
            baseGraph = g;

            // We construct a simple graph out of the input (multi-)graph
            // as a subgraph with no multiedges.
            // The removed edges are collected in multiEdgeList
            // Moreover, shortest cycles through these edges are constructed and
            // collected in mulitEdgeCycles

            UndirectedGraph simpleGraph = new UndirectedSubgraph(g, null, null);

            // Iterate over the edges and discard all edges with the same source and target
            //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'"
            for (System.Collections.IEnumerator it = g.edgeSet().GetEnumerator(); it.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'"
                Edge edge = (Edge)((DictionaryEntry)it.Current).Value;
                System.Object u = edge.Source;
                System.Object v = edge.Target;
                System.Collections.IList edges = simpleGraph.getAllEdges(u, v);
                if (edges.Count > 1)
                {
                    // Multiple edges between u and v.
                    // Keep the edge with the least weight


                    Edge minEdge = edge;
                    //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'"
                    for (System.Collections.IEnumerator jt = edges.GetEnumerator(); jt.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'"
                        Edge nextEdge = (Edge)jt.Current;
                        minEdge = nextEdge.Weight < minEdge.Weight ? nextEdge : minEdge;
                    }

                    //  ...and remove the others.
                    //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'"
                    for (System.Collections.IEnumerator jt = edges.GetEnumerator(); jt.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'"
                        Edge nextEdge = (Edge)jt.Current;
                        if (nextEdge != minEdge)
                        {
                            // Remove edge from the graph
                            simpleGraph.removeEdge(nextEdge);

                            // Create a new cycle through this edge by finding 
                            // a shortest path between the vertices of the edge
                            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
                            CSGraphT.SupportClass.SetSupport edgesOfCycle = new CSGraphT.SupportClass.HashSetSupport();
                            edgesOfCycle.Add(nextEdge);
                            edgesOfCycle.AddAll(DijkstraShortestPath.findPathBetween(simpleGraph, u, v));

                            multiEdgeList.Add(nextEdge);
                            mulitEdgeCycles.Add(new SimpleCycle(baseGraph, edgesOfCycle));
                        }
                    }
                }
            }

            System.Collections.IList biconnectedComponents = new BiconnectivityInspector(simpleGraph).biconnectedSets();

            for (IEnumerator it = biconnectedComponents.GetEnumerator(); it.MoveNext();)
            {
                CSGraphT.SupportClass.SetSupport edges = (CSGraphT.SupportClass.SetSupport)it.Current;
                //IList edges = (IList)it.Current;

                if (edges.Count > 1)
                {
                    CSGraphT.SupportClass.SetSupport vertices = new CSGraphT.SupportClass.HashSetSupport();
                    for (System.Collections.IEnumerator edgeIt = edges.GetEnumerator(); edgeIt.MoveNext(); )
                    {
                        Edge edge = (Edge)((DictionaryEntry)edgeIt.Current).Value;
                        vertices.Add(edge.Source);
                        vertices.Add(edge.Target);
                    }
                    UndirectedGraph subgraph = new UndirectedSubgraph(simpleGraph, vertices, edges);

                    SimpleCycleBasis cycleBasis = new SimpleCycleBasis(subgraph);

                    subgraphBases.Add(cycleBasis);
                }
                else
                {
                    Edge edge = (Edge)((DictionaryEntry)edges.GetEnumerator().Current).Value;
                    multiEdgeList.Add(edge);
                }
            }
        }
コード例 #6
0
ファイル: CycleBasis.cs プロジェクト: xuchuansheng/GenXSource
        private SimpleCycleBasis simpleBasis()
        {
            if (cachedCycleBasis == null)
            {
                System.Collections.IList cycles = new System.Collections.ArrayList();
                System.Collections.IList edgeList = new System.Collections.ArrayList();

                //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'"
                for (System.Collections.IEnumerator it = subgraphBases.GetEnumerator(); it.MoveNext(); )
                {
                    SimpleCycleBasis subgraphBase = (SimpleCycleBasis)it.Current;
                    SupportClass.ICollectionSupport.AddAll(cycles, subgraphBase.cycles());
                    SupportClass.ICollectionSupport.AddAll(edgeList, subgraphBase.edges());
                }

                SupportClass.ICollectionSupport.AddAll(cycles, mulitEdgeCycles);
                SupportClass.ICollectionSupport.AddAll(edgeList, multiEdgeList);

                //edgeList.addAll(baseGraph.edgeSet());


                cachedCycleBasis = new SimpleCycleBasis(cycles, edgeList, baseGraph);
            }

            return cachedCycleBasis;
        }