Example #1
0
 static private IList inducedVertices(IList edges)
 {
     IList inducedVertices = new CSGraphT.SupportClass.HashSetSupport();
     foreach (Edge edge in edges)
     {
         inducedVertices.Add(edge.Source);
         inducedVertices.Add(edge.Target);
     }
     return inducedVertices;
 }
Example #2
0
        static private IList inducedVertices(IList edges)
        {
            IList inducedVertices = new CSGraphT.SupportClass.HashSetSupport();

            foreach (Edge edge in edges)
            {
                inducedVertices.Add(edge.Source);
                inducedVertices.Add(edge.Target);
            }
            return(inducedVertices);
        }
Example #3
0
        /// <summary> Returns the essential cycles of this cycle basis.
        /// A essential cycle is contained in every minimum cycle basis of a graph.
        ///
        /// </summary>
        /// <returns> a <Code>Collection</code> of the essential cycles
        /// </returns>

        public virtual System.Collections.ICollection essentialCycles()
        {
            //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'"
            System.Collections.ICollection result = new CSGraphT.SupportClass.HashSetSupport();
            //minimize();

            //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 cycleBasis = (SimpleCycleBasis)it.Current;
                SupportClass.ICollectionSupport.AddAll(result, cycleBasis.essentialCycles());
            }

            return(result);
        }
        public virtual System.Collections.ICollection essentialCycles()
        {
            //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'"
            System.Collections.ICollection result = new CSGraphT.SupportClass.HashSetSupport();

            bool[][] a = getCycleEdgeIncidenceMatrix();

            bool[][] ai = inverseBinaryMatrix(a, cycles_Renamed_Field.Count);

            for (int i = 0; i < cycles_Renamed_Field.Count; i++)
            {

                // Construct kernel vector u
                bool[] u = new bool[edgeList.Count];
                for (int j = 0; j < cycles_Renamed_Field.Count; j++)
                {
                    u[j] = ai[j][i];
                }

                // Construct kernel vector u from a column of the inverse of a
                AuxiliaryGraph gu = new AuxiliaryGraph(this, graph, u);

                bool isEssential = true;

                System.Collections.IEnumerator vertexIterator = graph.vertexSet().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 (isEssential && vertexIterator.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'"
                    System.Object vertex = vertexIterator.Current;

                    System.Collections.ICollection incidentEdges = graph.edgesOf(vertex);

                    // check if the vertex is incident to an edge with u[edge] == 1
                    bool shouldSearchCycle = false;

                    //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 = incidentEdges.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)it.Current;
                        int index = getEdgeIndex(edge);
                        if (u[index])
                        {
                            shouldSearchCycle = true;
                            break;
                        }
                    }

                    if (shouldSearchCycle)
                    {

                        System.Object auxVertex0 = gu.auxVertex0(vertex);
                        System.Object auxVertex1 = gu.auxVertex1(vertex);


                        // Search for shortest paths
                        //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 minPaths = new MinimalPathIterator(gu, auxVertex0, auxVertex1); minPaths.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'"
                            System.Collections.IList auxPath = (System.Collections.IList)minPaths.Current;
                            System.Collections.IList edgesOfNewCycle = new System.Collections.ArrayList(auxPath.Count);

                            //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 = auxPath.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 auxEdge = (Edge)it.Current;

                                // Get the edge corresponding to the aux. edge
                                Edge e = (Edge)gu.edge(auxEdge);

                                edgesOfNewCycle.Add(e);
                            }

                            SimpleCycle cycle = new SimpleCycle(graph, edgesOfNewCycle);

                            if (cycle.weight() > ((SimpleCycle)cycles_Renamed_Field[i]).weight())
                            {
                                break;
                            }

                            if (!cycle.Equals((SimpleCycle)cycles_Renamed_Field[i]))
                            {
                                isEssential = false;
                                break;
                            }
                        }
                    }
                }

                if (isEssential)
                {
                    SupportClass.ICollectionSupport.Add(result, (SimpleCycle)cycles_Renamed_Field[i]);
                }
            }

            return result;
        }
        private void createMinimumCycleBasis()
        {
            org._3pq.jgrapht.Graph subgraph = new Subgraph(graph, null, null);

            CSGraphT.SupportClass.SetSupport remainingEdges = new CSGraphT.SupportClass.HashSetSupport(graph.edgeSet());
            //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 selectedEdges = new CSGraphT.SupportClass.HashSetSupport();

            while (!(remainingEdges.Count == 0))
            {
                //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)remainingEdges.GetEnumerator().Current;

                subgraph.removeEdge(edge);

                // Compute a shortest cycle through edge
                System.Collections.IList path = BFSShortestPath.findPathBetween(subgraph, edge.Source, edge.Target);
                path.Add(edge);
                SimpleCycle cycle = new SimpleCycle(graph, path);

                subgraph.addEdge(edge);

                selectedEdges.Add(edge);

                cycles_Renamed_Field.Insert(0, cycle);
                edgeList.Insert(0, edge);

                SupportClass.ICollectionSupport.RemoveAll(remainingEdges, path);
            }

            subgraph.removeAllEdges(selectedEdges);

            // The cycles just created are already minimal, so we can start minimizing at startIndex
            int startIndex = cycles_Renamed_Field.Count;

            // Now we perform a breadth first traversal and build a fundamental tree base
            // ("Kirchhoff base") of the remaining subgraph

            System.Object currentVertex = graph.vertexSet()[0];

            // We build a spanning tree as a directed graph to easily find the parent of a
            // vertex in the tree. This means however that we have to create new Edge objects
            // for the tree and can't just use the Edge objects of the graph, since the
            // the edge in the graph might have a wrong or no direction.

            DirectedGraph spanningTree = new SimpleDirectedGraph();

            //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 visitedEdges = new CSGraphT.SupportClass.HashSetSupport();

            // FIFO for the BFS
            //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'"
            System.Collections.ArrayList vertexQueue = new System.Collections.ArrayList();

            // currentVertex is the root of the spanning tree
            spanningTree.addVertex(currentVertex);

            vertexQueue.Insert(vertexQueue.Count, currentVertex);

            // We need to remember the tree edges so we can add them at once to the
            // index list for the incidence matrix

            System.Collections.IList treeEdges = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));

            while (!(vertexQueue.Count == 0))
            {
                System.Object tempObject;
                tempObject = vertexQueue[0];
                vertexQueue.RemoveAt(0);
                currentVertex = tempObject;

                System.Collections.IEnumerator edges = subgraph.edgesOf(currentVertex).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 (edges.MoveNext())
                {
                    // find a neighbour vertex of the current vertex 
                    //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)edges.Current;

                    if (!visitedEdges.Contains(edge))
                    {

                        // mark edge as visited
                        visitedEdges.Add(edge);

                        System.Object nextVertex = edge.oppositeVertex(currentVertex);

                        if (!spanningTree.containsVertex(nextVertex))
                        {
                            // tree edge

                            treeEdges.Add(edge);

                            spanningTree.addVertex(nextVertex);

                            // create a new (directed) Edge object (as explained above)
                            spanningTree.addEdge(currentVertex, nextVertex);

                            // add the next vertex to the BFS-FIFO
                            vertexQueue.Insert(vertexQueue.Count, nextVertex);
                        }
                        else
                        {
                            // non-tree edge

                            // This edge defines a cycle together with the edges of the spanning tree
                            // along the path to the root of the tree. We create a new cycle containing 
                            // these edges (not the tree edges, but the corresponding edges in the graph)

                            System.Collections.IList edgesOfCycle = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));

                            // follow the path to the root of the tree

                            System.Object vertex = currentVertex;

                            // get parent of vertex
                            System.Collections.IList incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                            System.Object parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);

                            while (parent != null)
                            {
                                // add the corresponding edge to the cycle
                                edgesOfCycle.Add(subgraph.getEdge(vertex, parent));

                                // go up the tree
                                vertex = parent;

                                // get parent of vertex
                                incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                                parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);
                            }

                            // do the same thing for nextVertex
                            vertex = nextVertex;

                            // get parent of vertex
                            incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                            parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);

                            while (parent != null)
                            {
                                edgesOfCycle.Add(subgraph.getEdge(vertex, parent));
                                vertex = parent;

                                // get parent of vertex
                                incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                                parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);
                            }

                            // finally, add the non-tree edge to the cycle
                            edgesOfCycle.Add(edge);

                            // add the edge to the index list for the incidence matrix
                            edgeList.Add(edge);

                            SimpleCycle newCycle = new SimpleCycle(graph, edgesOfCycle);

                            cycles_Renamed_Field.Add(newCycle);
                        }
                    }
                }
            }

            // Add all the tree edges to the index list for the incidence matrix
            SupportClass.ICollectionSupport.AddAll(edgeList, treeEdges);

            edgeIndexMap = createEdgeIndexMap(edgeList);

            // Now the index list is ordered: first the non-tree edges, then the tree edge.
            // Moreover, since the cycles and the corresponding non-tree edge have been added
            // to their lists in the same order, the incidence matrix is in upper triangular form.

            // Now we can minimize the cycles created from the tree base
            minimize(startIndex);
        }
Example #6
0
        /// <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);
                }
            }
        }
Example #7
0
 /// <summary>  Return the RMSD of the heavy atoms between the 2 aligned molecules.
 /// 
 /// </summary>
 /// <param name="firstAtomContainer">               the (largest) first aligned AtomContainer which is the reference
 /// </param>
 /// <param name="secondAtomContainer">              the second aligned AtomContainer
 /// </param>
 /// <param name="mappedAtoms">            			Map: a Map of the mapped atoms
 /// </param>
 /// <param name="Coords3d">           			    boolean: true if moecules has 3D coords, false if molecules has 2D coords
 /// </param>
 /// <returns>                   				double: the value of the RMSD 
 /// </returns>
 /// <exception cref="CDK">*
 /// 
 /// </exception>
 public static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, System.Collections.IDictionary mappedAtoms, bool Coords3d)
 {
     //System.out.println("**** GT getAllAtomRMSD ****");
     double sum = 0;
     double RMSD = 0;
     //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
     System.Collections.IEnumerator firstAtoms = new CSGraphT.SupportClass.HashSetSupport(mappedAtoms.Keys).GetEnumerator();
     int firstAtomNumber = 0;
     int secondAtomNumber = 0;
     int n = 0;
     //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 (firstAtoms.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'"
         firstAtomNumber = ((System.Int32)firstAtoms.Current);
         try
         {
             secondAtomNumber = ((System.Int32)mappedAtoms[(System.Int32)firstAtomNumber]);
             IAtom firstAtom = firstAtomContainer.getAtomAt(firstAtomNumber);
             if (!firstAtom.Symbol.Equals("H"))
             {
                 if (Coords3d)
                 {
                     sum = sum + System.Math.Pow(((Point3d)firstAtom.getPoint3d()).distance(secondAtomContainer.getAtomAt(secondAtomNumber).getPoint3d()), 2);
                     n++;
                 }
                 else
                 {
                     sum = sum + System.Math.Pow(((Point2d)firstAtom.getPoint2d()).distance(secondAtomContainer.getAtomAt(secondAtomNumber).getPoint2d()), 2);
                     n++;
                 }
             }
         }
         catch (System.Exception ex)
         {
         }
     }
     RMSD = System.Math.Sqrt(sum / n);
     return RMSD;
 }
Example #8
0
 /// <summary>  Return the variation of each angle value between the 2 aligned molecules.
 /// 
 /// </summary>
 /// <param name="firstAtomContainer">               the (largest) first aligned AtomContainer which is the reference
 /// </param>
 /// <param name="secondAtomContainer">              the second aligned AtomContainer
 /// </param>
 /// <param name="mappedAtoms">            			Map: a Map of the mapped atoms
 /// </param>
 /// <returns>                   				double: the value of the RMSD 
 /// </returns>
 /// <exception cref="CDK">*
 /// 
 /// </exception>
 public static double getAngleRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, System.Collections.IDictionary mappedAtoms)
 {
     //System.out.println("**** GT getAngleRMSD ****");
     //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
     System.Collections.IEnumerator firstAtoms = new CSGraphT.SupportClass.HashSetSupport(mappedAtoms.Keys).GetEnumerator();
     //System.out.println("mappedAtoms:"+mappedAtoms.toString());
     IAtom firstAtomfirstAC = null;
     IAtom centerAtomfirstAC = null;
     IAtom firstAtomsecondAC = null;
     IAtom secondAtomsecondAC = null;
     IAtom centerAtomsecondAC = null;
     double angleFirstMolecule = 0;
     double angleSecondMolecule = 0;
     double sum = 0;
     double n = 0;
     //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 (firstAtoms.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'"
         int firstAtomNumber = ((System.Int32)firstAtoms.Current);
         centerAtomfirstAC = firstAtomContainer.getAtomAt(firstAtomNumber);
         IAtom[] connectedAtoms = firstAtomContainer.getConnectedAtoms(centerAtomfirstAC);
         if (connectedAtoms.Length > 1)
         {
             //System.out.println("If "+centerAtomfirstAC.getSymbol()+" is the center atom :");
             for (int i = 0; i < connectedAtoms.Length - 1; i++)
             {
                 firstAtomfirstAC = connectedAtoms[i];
                 for (int j = i + 1; j < connectedAtoms.Length; j++)
                 {
                     angleFirstMolecule = getAngle(centerAtomfirstAC, firstAtomfirstAC, connectedAtoms[j]);
                     centerAtomsecondAC = secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(centerAtomfirstAC)]));
                     firstAtomsecondAC = secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(firstAtomfirstAC)]));
                     secondAtomsecondAC = secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(connectedAtoms[j])]));
                     angleSecondMolecule = getAngle(centerAtomsecondAC, firstAtomsecondAC, secondAtomsecondAC);
                     sum = sum + System.Math.Pow(angleFirstMolecule - angleSecondMolecule, 2);
                     n++;
                     //System.out.println("Error for the "+firstAtomfirstAC.getSymbol().toLowerCase()+"-"+centerAtomfirstAC.getSymbol()+"-"+connectedAtoms[j].getSymbol().toLowerCase()+" Angle :"+deltaAngle+" degrees");
                 }
             }
         } //if
     }
     return System.Math.Sqrt(sum / n);
 }
Example #9
0
 /// <summary>  Return the RMSD of bonds length between the 2 aligned molecules.
 /// 
 /// </summary>
 /// <param name="firstAtomContainer">               the (largest) first aligned AtomContainer which is the reference
 /// </param>
 /// <param name="secondAtomContainer">              the second aligned AtomContainer
 /// </param>
 /// <param name="mappedAtoms">            			Map: a Map of the mapped atoms
 /// </param>
 /// <param name="Coords3d">           			    boolean: true if moecules has 3D coords, false if molecules has 2D coords
 /// </param>
 /// <returns>                   				double: all the RMSD of bonds length
 /// </returns>
 /// <exception cref="CDK">*
 /// 
 /// </exception>
 public static double getBondLengthRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, System.Collections.IDictionary mappedAtoms, bool Coords3d)
 {
     //System.out.println("**** GT getBondLengthRMSD ****");
     //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
     System.Collections.IEnumerator firstAtoms = new CSGraphT.SupportClass.HashSetSupport(mappedAtoms.Keys).GetEnumerator();
     IAtom centerAtomFirstMolecule = null;
     IAtom centerAtomSecondMolecule = null;
     IAtom[] connectedAtoms = null;
     double sum = 0;
     double n = 0;
     double distance1 = 0;
     double distance2 = 0;
     setVisitedFlagsToFalse(firstAtomContainer);
     setVisitedFlagsToFalse(secondAtomContainer);
     //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 (firstAtoms.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'"
         centerAtomFirstMolecule = firstAtomContainer.getAtomAt(((System.Int32)firstAtoms.Current));
         centerAtomFirstMolecule.setFlag(CDKConstants.VISITED, true);
         centerAtomSecondMolecule = secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(centerAtomFirstMolecule)]));
         connectedAtoms = firstAtomContainer.getConnectedAtoms(centerAtomFirstMolecule);
         for (int i = 0; i < connectedAtoms.Length; i++)
         {
             //this step is built to know if the program has already calculate a bond length (so as not to have duplicate values)
             if (!connectedAtoms[i].getFlag(CDKConstants.VISITED))
             {
                 if (Coords3d)
                 {
                     distance1 = ((Point3d)centerAtomFirstMolecule.getPoint3d()).distance(connectedAtoms[i].getPoint3d());
                     distance2 = ((Point3d)centerAtomSecondMolecule.getPoint3d()).distance(secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(connectedAtoms[i])])).getPoint3d());
                     sum = sum + System.Math.Pow((distance1 - distance2), 2);
                     n++;
                 }
                 else
                 {
                     distance1 = ((Point2d)centerAtomFirstMolecule.getPoint2d()).distance(connectedAtoms[i].getPoint2d());
                     distance2 = ((Point2d)centerAtomSecondMolecule.getPoint2d()).distance(secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(connectedAtoms[i])])).getPoint2d());
                     sum = sum + System.Math.Pow((distance1 - distance2), 2);
                     n++;
                 }
             }
         }
     }
     setVisitedFlagsToFalse(firstAtomContainer);
     setVisitedFlagsToFalse(secondAtomContainer);
     return System.Math.Sqrt(sum / n);
 }
Example #10
0
 /// <summary>  Returns the atoms which are closes to an atom in an AtomContainer by
 /// distance in 3d.
 /// 
 /// </summary>
 /// <param name="ac">               The AtomContainer to examine
 /// </param>
 /// <param name="a">                the atom to start from
 /// </param>
 /// <param name="max">              the number of neighbours to return
 /// </param>
 /// <returns>                   the average bond length
 /// </returns>
 /// <exception cref="CDKException"> Description of the Exception
 /// </exception>
 public static System.Collections.ArrayList findClosestInSpace(IAtomContainer ac, IAtom a, int max)
 {
     IAtom[] atoms = ac.Atoms;
     Point3d originalPoint = a.getPoint3d();
     if (originalPoint == null)
     {
         throw new CDKException("No point3d, but findClosestInSpace is working on point3ds");
     }
     //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'"
     //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
     System.Collections.IDictionary hm = new System.Collections.SortedList();
     for (int i = 0; i < atoms.Length; i++)
     {
         if (atoms[i] != a)
         {
             if (atoms[i].getPoint3d() == null)
             {
                 throw new CDKException("No point3d, but findClosestInSpace is working on point3ds");
             }
             double distance = atoms[i].getPoint3d().distance(originalPoint);
             hm[(double)distance] = atoms[i];
         }
     }
     //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
     CSGraphT.SupportClass.SetSupport ks = new CSGraphT.SupportClass.HashSetSupport(hm.Keys);
     System.Collections.IEnumerator it = ks.GetEnumerator();
     System.Collections.ArrayList returnValue = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     int i2 = 0;
     //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 (it.MoveNext() && i2 < max)
     {
         //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'"
         returnValue.Add(hm[it.Current]);
         i2++;
     }
     return (returnValue);
 }
Example #11
0
        /// <summary> Writes a Molecule to an OutputStream in MDL sdf format.
        ///
        /// </summary>
        /// <param name="container"> Molecule that is written to an OutputStream
        /// </param>
        /// <param name="isVisible">Should a certain atom be written to mdl?
        /// </param>
        public virtual void writeMolecule(IMolecule container, bool[] isVisible)
        {
            System.String line = "";
            // taking care of the $$$$ signs:
            // we do not write such a sign at the end of the first molecule, thus we have to write on BEFORE the second molecule
            if (moleculeNumber == 2)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            // write header block
            // lines get shortened to 80 chars, that's in the spec
            System.String title = (System.String)container.getProperty(CDKConstants.TITLE);
            if (title == null)
            {
                title = "";
            }
            if (title.Length > 80)
            {
                title = title.Substring(0, (80) - (0));
            }
            writer.Write(title + "\n");

            /* From CTX spec
             * This line has the format:
             * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR
             * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> )
             * User's first and last initials (l), program name (P),
             * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s),
             * energy (E) if modeling program input, internal registry number (R)
             * if input through MDL form.
             * A blank line can be substituted for line 2.
             */
            writer.Write("  CDK    ");
            //UPGRADE_ISSUE: Constructor 'java.text.SimpleDateFormat.SimpleDateFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextSimpleDateFormat'"
            //UPGRADE_TODO: The equivalent in .NET for method 'java.util.Calendar.getTime' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            System.TimeZone generatedAux3 = System.TimeZone.CurrentTimeZone;
            //writer.Write(SupportClass.FormatDateTime(new SimpleDateFormat("M/d/y,H:m", new System.Globalization.CultureInfo("en-US")), SupportClass.CalendarManager.manager.GetDateTime(new System.Globalization.GregorianCalendar())));
            writer.Write('\n');

            System.String comment = (System.String)container.getProperty(CDKConstants.REMARK);
            if (comment == null)
            {
                comment = "";
            }
            if (comment.Length > 80)
            {
                comment = comment.Substring(0, (80) - (0));
            }
            writer.Write(comment + "\n");

            // write Counts line
            int upToWhichAtom = 0;

            for (int i = 0; i < isVisible.Length; i++)
            {
                if (isVisible[i])
                {
                    upToWhichAtom++;
                }
            }
            line += formatMDLInt(upToWhichAtom, 3);
            int numberOfBonds = 0;

            if (upToWhichAtom < container.AtomCount)
            {
                for (int i = 0; i < container.getBondCount(); i++)
                {
                    if (isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[1])])
                    {
                        numberOfBonds++;
                    }
                }
            }
            else
            {
                numberOfBonds = container.getBondCount();
            }
            line += formatMDLInt(numberOfBonds, 3);
            line += "  0  0  0  0  0  0  0  0999 V2000\n";
            writer.Write(line);

            // write Atom block
            IAtom[] atoms = container.Atoms;
            for (int f = 0; f < atoms.Length; f++)
            {
                if (isVisible[f])
                {
                    IAtom atom = atoms[f];
                    line = "";
                    if (atom.getPoint3d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += (formatMDLFloat((float)atom.Z3d) + " ");
                    }
                    else if (atom.getPoint2d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X2d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y2d);
                        line += "    0.0000 ";
                    }
                    else
                    {
                        // if no coordinates available, then output a number
                        // of zeros
                        line += formatMDLFloat((float)0.0);
                        line += formatMDLFloat((float)0.0);
                        line += (formatMDLFloat((float)0.0) + " ");
                    }
                    if (container.getAtomAt(f) is IPseudoAtom)
                    {
                        line += formatMDLString(((IPseudoAtom)container.getAtomAt(f)).Label, 3);
                    }
                    else
                    {
                        line += formatMDLString(container.getAtomAt(f).Symbol, 3);
                    }
                    line += " 0  0  0  0  0  0  0  0  0  0  0  0";
                    writer.Write(line);
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write Bond block
            IBond[] bonds = container.Bonds;
            for (int g = 0; g < bonds.Length; g++)
            {
                if (upToWhichAtom == container.AtomCount || (isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[1])]))
                {
                    IBond bond = bonds[g];
                    if (bond.getAtoms().Length != 2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        //logger.warn("Skipping bond with more/less than two atoms: " + bond);
                    }
                    else
                    {
                        if (bond.Stereo == CDKConstants.STEREO_BOND_UP_INV || bond.Stereo == CDKConstants.STEREO_BOND_DOWN_INV)
                        {
                            // turn around atom coding to correct for inv stereo
                            line  = formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                        }
                        else
                        {
                            line  = formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                        }
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLInt((int)bond.Order, 3);
                        line += "  ";
                        switch (bond.Stereo)
                        {
                        case CDKConstants.STEREO_BOND_UP:
                            line += "1";
                            break;

                        case CDKConstants.STEREO_BOND_UP_INV:
                            line += "1";
                            break;

                        case CDKConstants.STEREO_BOND_DOWN:
                            line += "6";
                            break;

                        case CDKConstants.STEREO_BOND_DOWN_INV:
                            line += "6";
                            break;

                        default:
                            line += "0";
                            break;
                        }
                        line += "  0  0  0 ";
                        writer.Write(line);
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // write formal atomic charges
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom   = atoms[i];
                int   charge = atom.getFormalCharge();
                if (charge != 0)
                {
                    writer.Write("M  CHG  1 ");
                    writer.Write(formatMDLInt(i + 1, 3));
                    writer.Write(" ");
                    writer.Write(formatMDLInt(charge, 3));
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write formal isotope information
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom = atoms[i];
                if (!(atom is IPseudoAtom))
                {
                    int atomicMass = atom.MassNumber;
                    int majorMass  = IsotopeFactory.getInstance(atom.Builder).getMajorIsotope(atom.Symbol).MassNumber;
                    if (atomicMass != 0 && atomicMass != majorMass)
                    {
                        writer.Write("M  ISO  1 ");
                        writer.Write(formatMDLInt(i + 1, 3));
                        writer.Write(" ");
                        writer.Write(formatMDLInt(atomicMass, 3));
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // close molecule
            writer.Write("M  END");
            //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            writer.WriteLine();
            //write sdfields, if any
            if (sdFields != null)
            {
                //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
                CSGraphT.SupportClass.SetSupport set_Renamed = new CSGraphT.SupportClass.HashSetSupport(sdFields.Keys);
                System.Collections.IEnumerator   iterator    = set_Renamed.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 (iterator.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'"
                    System.Object element = iterator.Current;
                    writer.Write("> <" + ((System.String)element) + ">");
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    writer.Write(sdFields[element].ToString());
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }
            // taking care of the $$$$ signs:
            // we write such a sign at the end of all except the first molecule
            if (moleculeNumber != 1)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            moleculeNumber++;
            writer.Flush();
        }
Example #12
0
        /// <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);
                }
            }
        }
Example #13
0
        /// <summary> Returns the essential cycles of this cycle basis.
        /// A essential cycle is contained in every minimum cycle basis of a graph.
        /// 
        /// </summary>
        /// <returns> a <Code>Collection</code> of the essential cycles
        /// </returns>

        public virtual System.Collections.ICollection essentialCycles()
        {
            //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'"
            System.Collections.ICollection result = new CSGraphT.SupportClass.HashSetSupport();
            //minimize();

            //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 cycleBasis = (SimpleCycleBasis)it.Current;
                SupportClass.ICollectionSupport.AddAll(result, cycleBasis.essentialCycles());
            }

            return result;
        }
        private System.Collections.IList lazyFindBiconnectedSets()
        {
            if (biconnectedSets_Renamed_Field == null)
            {
                biconnectedSets_Renamed_Field = new System.Collections.ArrayList();

                IList inspector = new ConnectivityInspector(graph).connectedSets();
                System.Collections.IEnumerator connectedSets = inspector.GetEnumerator();

                while (connectedSets.MoveNext())
                {
                    object obj = ((DictionaryEntry)connectedSets.Current).Value;
                    if (!(obj is CSGraphT.SupportClass.HashSetSupport))
                    {
                        continue;
                    }
                    CSGraphT.SupportClass.SetSupport connectedSet = (CSGraphT.SupportClass.SetSupport)obj;
                    if (connectedSet.Count == 1)
                    {
                        continue;
                    }

                    org._3pq.jgrapht.Graph subgraph = new Subgraph(graph, connectedSet, null);

                    // do DFS

                    // Stack for the DFS
                    System.Collections.ArrayList vertexStack = new System.Collections.ArrayList();

                    CSGraphT.SupportClass.SetSupport visitedVertices = new CSGraphT.SupportClass.HashSetSupport();
                    IDictionary parent      = new System.Collections.Hashtable();
                    IList       dfsVertices = new System.Collections.ArrayList();

                    CSGraphT.SupportClass.SetSupport treeEdges = new CSGraphT.SupportClass.HashSetSupport();

                    System.Object currentVertex = subgraph.vertexSet()[0];//.ToArray()[0];

                    vertexStack.Add(currentVertex);
                    visitedVertices.Add(currentVertex);

                    while (!(vertexStack.Count == 0))
                    {
                        currentVertex = SupportClass.StackSupport.Pop(vertexStack);

                        System.Object parentVertex = parent[currentVertex];

                        if (parentVertex != null)
                        {
                            Edge edge = subgraph.getEdge(parentVertex, currentVertex);

                            // tree edge
                            treeEdges.Add(edge);
                        }

                        visitedVertices.Add(currentVertex);

                        dfsVertices.Add(currentVertex);

                        System.Collections.IEnumerator edges = subgraph.edgesOf(currentVertex).GetEnumerator();
                        while (edges.MoveNext())
                        {
                            // find a neighbour vertex of the current vertex
                            Edge edge = (Edge)edges.Current;

                            if (!treeEdges.Contains(edge))
                            {
                                System.Object nextVertex = edge.oppositeVertex(currentVertex);

                                if (!visitedVertices.Contains(nextVertex))
                                {
                                    vertexStack.Add(nextVertex);

                                    parent[nextVertex] = currentVertex;
                                }
                                else
                                {
                                    // non-tree edge
                                }
                            }
                        }
                    }

                    // DFS is finished. Now create the auxiliary graph h
                    // Add all the tree edges as vertices in h
                    SimpleGraph h = new SimpleGraph();

                    h.addAllVertices(treeEdges);

                    visitedVertices.Clear();

                    CSGraphT.SupportClass.SetSupport connected = new CSGraphT.SupportClass.HashSetSupport();

                    for (System.Collections.IEnumerator it = dfsVertices.GetEnumerator(); it.MoveNext();)
                    {
                        System.Object v = it.Current;

                        visitedVertices.Add(v);

                        // find all adjacent non-tree edges
                        for (System.Collections.IEnumerator adjacentEdges = subgraph.edgesOf(v).GetEnumerator(); adjacentEdges.MoveNext();)
                        {
                            Edge l = (Edge)adjacentEdges.Current;
                            if (!treeEdges.Contains(l))
                            {
                                h.addVertex(l);
                                System.Object u = l.oppositeVertex(v);

                                // we need to check if (u,v) is a back-edge
                                if (!visitedVertices.Contains(u))
                                {
                                    while (u != v)
                                    {
                                        System.Object pu = parent[u];
                                        Edge          f  = subgraph.getEdge(u, pu);

                                        h.addEdge(f, l);

                                        if (!connected.Contains(f))
                                        {
                                            connected.Add(f);
                                            u = pu;
                                        }
                                        else
                                        {
                                            u = v;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    ConnectivityInspector connectivityInspector = new ConnectivityInspector(h);

                    biconnectedSets_Renamed_Field.Add(connectivityInspector.connectedSets());
                }
            }

            return(biconnectedSets_Renamed_Field);
        }
Example #15
0
        /// <summary> Writes a Molecule to an OutputStream in MDL sdf format.
        /// 
        /// </summary>
        /// <param name="container"> Molecule that is written to an OutputStream
        /// </param>
        /// <param name="isVisible">Should a certain atom be written to mdl?
        /// </param>
        public virtual void writeMolecule(IMolecule container, bool[] isVisible)
        {
            System.String line = "";
            // taking care of the $$$$ signs:
            // we do not write such a sign at the end of the first molecule, thus we have to write on BEFORE the second molecule
            if (moleculeNumber == 2)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            // write header block
            // lines get shortened to 80 chars, that's in the spec
            System.String title = (System.String)container.getProperty(CDKConstants.TITLE);
            if (title == null)
                title = "";
            if (title.Length > 80)
                title = title.Substring(0, (80) - (0));
            writer.Write(title + "\n");

            /* From CTX spec
            * This line has the format:
            * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR
            * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> )
            * User's first and last initials (l), program name (P),
            * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s), 
            * energy (E) if modeling program input, internal registry number (R) 
            * if input through MDL form.
            * A blank line can be substituted for line 2.
            */
            writer.Write("  CDK    ");
            //UPGRADE_ISSUE: Constructor 'java.text.SimpleDateFormat.SimpleDateFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextSimpleDateFormat'"
            //UPGRADE_TODO: The equivalent in .NET for method 'java.util.Calendar.getTime' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            System.TimeZone generatedAux3 = System.TimeZone.CurrentTimeZone;
            //writer.Write(SupportClass.FormatDateTime(new SimpleDateFormat("M/d/y,H:m", new System.Globalization.CultureInfo("en-US")), SupportClass.CalendarManager.manager.GetDateTime(new System.Globalization.GregorianCalendar())));
            writer.Write('\n');

            System.String comment = (System.String)container.getProperty(CDKConstants.REMARK);
            if (comment == null)
                comment = "";
            if (comment.Length > 80)
                comment = comment.Substring(0, (80) - (0));
            writer.Write(comment + "\n");

            // write Counts line
            int upToWhichAtom = 0;
            for (int i = 0; i < isVisible.Length; i++)
            {
                if (isVisible[i])
                    upToWhichAtom++;
            }
            line += formatMDLInt(upToWhichAtom, 3);
            int numberOfBonds = 0;
            if (upToWhichAtom < container.AtomCount)
            {
                for (int i = 0; i < container.getBondCount(); i++)
                {
                    if (isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[1])])
                        numberOfBonds++;
                }
            }
            else
            {
                numberOfBonds = container.getBondCount();
            }
            line += formatMDLInt(numberOfBonds, 3);
            line += "  0  0  0  0  0  0  0  0999 V2000\n";
            writer.Write(line);

            // write Atom block
            IAtom[] atoms = container.Atoms;
            for (int f = 0; f < atoms.Length; f++)
            {
                if (isVisible[f])
                {
                    IAtom atom = atoms[f];
                    line = "";
                    if (atom.getPoint3d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += (formatMDLFloat((float)atom.Z3d) + " ");
                    }
                    else if (atom.getPoint2d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X2d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y2d);
                        line += "    0.0000 ";
                    }
                    else
                    {
                        // if no coordinates available, then output a number
                        // of zeros
                        line += formatMDLFloat((float)0.0);
                        line += formatMDLFloat((float)0.0);
                        line += (formatMDLFloat((float)0.0) + " ");
                    }
                    if (container.getAtomAt(f) is IPseudoAtom)
                        line += formatMDLString(((IPseudoAtom)container.getAtomAt(f)).Label, 3);
                    else
                        line += formatMDLString(container.getAtomAt(f).Symbol, 3);
                    line += " 0  0  0  0  0  0  0  0  0  0  0  0";
                    writer.Write(line);
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write Bond block
            IBond[] bonds = container.Bonds;
            for (int g = 0; g < bonds.Length; g++)
            {
                if (upToWhichAtom == container.AtomCount || (isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[1])]))
                {
                    IBond bond = bonds[g];
                    if (bond.getAtoms().Length != 2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        //logger.warn("Skipping bond with more/less than two atoms: " + bond);
                    }
                    else
                    {
                        if (bond.Stereo == CDKConstants.STEREO_BOND_UP_INV || bond.Stereo == CDKConstants.STEREO_BOND_DOWN_INV)
                        {
                            // turn around atom coding to correct for inv stereo
                            line = formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                        }
                        else
                        {
                            line = formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                        }
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLInt((int)bond.Order, 3);
                        line += "  ";
                        switch (bond.Stereo)
                        {

                            case CDKConstants.STEREO_BOND_UP:
                                line += "1";
                                break;

                            case CDKConstants.STEREO_BOND_UP_INV:
                                line += "1";
                                break;

                            case CDKConstants.STEREO_BOND_DOWN:
                                line += "6";
                                break;

                            case CDKConstants.STEREO_BOND_DOWN_INV:
                                line += "6";
                                break;

                            default:
                                line += "0";
                                break;

                        }
                        line += "  0  0  0 ";
                        writer.Write(line);
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // write formal atomic charges
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom = atoms[i];
                int charge = atom.getFormalCharge();
                if (charge != 0)
                {
                    writer.Write("M  CHG  1 ");
                    writer.Write(formatMDLInt(i + 1, 3));
                    writer.Write(" ");
                    writer.Write(formatMDLInt(charge, 3));
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write formal isotope information
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom = atoms[i];
                if (!(atom is IPseudoAtom))
                {
                    int atomicMass = atom.MassNumber;
                    int majorMass = IsotopeFactory.getInstance(atom.Builder).getMajorIsotope(atom.Symbol).MassNumber;
                    if (atomicMass != 0 && atomicMass != majorMass)
                    {
                        writer.Write("M  ISO  1 ");
                        writer.Write(formatMDLInt(i + 1, 3));
                        writer.Write(" ");
                        writer.Write(formatMDLInt(atomicMass, 3));
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // close molecule
            writer.Write("M  END");
            //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            writer.WriteLine();
            //write sdfields, if any
            if (sdFields != null)
            {
                //UPGRADE_TODO: Method 'java.util.Map.keySet' 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_javautilMapkeySet'"
                CSGraphT.SupportClass.SetSupport set_Renamed = new CSGraphT.SupportClass.HashSetSupport(sdFields.Keys);
                System.Collections.IEnumerator iterator = set_Renamed.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 (iterator.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'"
                    System.Object element = iterator.Current;
                    writer.Write("> <" + ((System.String)element) + ">");
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    writer.Write(sdFields[element].ToString());
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }
            // taking care of the $$$$ signs:
            // we write such a sign at the end of all except the first molecule
            if (moleculeNumber != 1)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            moleculeNumber++;
            writer.Flush();
        }
		private System.Collections.IList lazyFindBiconnectedSets()
		{
			if (biconnectedSets_Renamed_Field == null)
			{
				biconnectedSets_Renamed_Field = new System.Collections.ArrayList();
				
                IList inspector = new ConnectivityInspector(graph).connectedSets();
                System.Collections.IEnumerator connectedSets = inspector.GetEnumerator();
				
				while (connectedSets.MoveNext())
				{
                    object obj = ((DictionaryEntry)connectedSets.Current).Value;
                    if (!(obj is CSGraphT.SupportClass.HashSetSupport))
                        continue;
					CSGraphT.SupportClass.SetSupport connectedSet = (CSGraphT.SupportClass.SetSupport)obj;
					if (connectedSet.Count == 1)
					{
						continue;
					}
					
					org._3pq.jgrapht.Graph subgraph = new Subgraph(graph, connectedSet, null);
					
					// do DFS
					
					// Stack for the DFS
					System.Collections.ArrayList vertexStack = new System.Collections.ArrayList();
					
					CSGraphT.SupportClass.SetSupport visitedVertices = new CSGraphT.SupportClass.HashSetSupport();
					IDictionary parent = new System.Collections.Hashtable();
					IList dfsVertices = new System.Collections.ArrayList();
					
					CSGraphT.SupportClass.SetSupport treeEdges = new CSGraphT.SupportClass.HashSetSupport();

                    System.Object currentVertex = subgraph.vertexSet()[0];//.ToArray()[0];

					vertexStack.Add(currentVertex);
					visitedVertices.Add(currentVertex);
					
					while (!(vertexStack.Count == 0))
					{
						currentVertex = SupportClass.StackSupport.Pop(vertexStack);
						
						System.Object parentVertex = parent[currentVertex];
						
						if (parentVertex != null)
						{
							Edge edge = subgraph.getEdge(parentVertex, currentVertex);
							
							// tree edge
							treeEdges.Add(edge);
						}
						
						visitedVertices.Add(currentVertex);
						
						dfsVertices.Add(currentVertex);
						
						System.Collections.IEnumerator edges = subgraph.edgesOf(currentVertex).GetEnumerator();
						while (edges.MoveNext())
						{
							// find a neighbour vertex of the current vertex 
							Edge edge = (Edge)edges.Current;
							
							if (!treeEdges.Contains(edge))
							{
								System.Object nextVertex = edge.oppositeVertex(currentVertex);
								
								if (!visitedVertices.Contains(nextVertex))
								{
									vertexStack.Add(nextVertex);
									
									parent[nextVertex] = currentVertex;
								}
								else
								{
									// non-tree edge
								}
							}
						}
					}
					
					// DFS is finished. Now create the auxiliary graph h
					// Add all the tree edges as vertices in h
					SimpleGraph h = new SimpleGraph();
					
					h.addAllVertices(treeEdges);
					
					visitedVertices.Clear();
					
					CSGraphT.SupportClass.SetSupport connected = new CSGraphT.SupportClass.HashSetSupport();
					
					for (System.Collections.IEnumerator it = dfsVertices.GetEnumerator(); it.MoveNext(); )
					{
						System.Object v = it.Current;
						
						visitedVertices.Add(v);
						
						// find all adjacent non-tree edges
						for (System.Collections.IEnumerator adjacentEdges = subgraph.edgesOf(v).GetEnumerator(); adjacentEdges.MoveNext();)
						{
							Edge l = (Edge)adjacentEdges.Current;
							if (!treeEdges.Contains(l))
							{
								h.addVertex(l);
								System.Object u = l.oppositeVertex(v);
								
								// we need to check if (u,v) is a back-edge
								if (!visitedVertices.Contains(u))
								{
									while (u != v)
									{
										System.Object pu = parent[u];
										Edge f = subgraph.getEdge(u, pu);
										
										h.addEdge(f, l);
										
										if (!connected.Contains(f))
										{
											connected.Add(f);
											u = pu;
										}
										else
										{
											u = v;
										}
									}
								}
							}
						}
					}
					
					ConnectivityInspector connectivityInspector = new ConnectivityInspector(h);
					
					biconnectedSets_Renamed_Field.Add(connectivityInspector.connectedSets());
				}
			}
			
			return biconnectedSets_Renamed_Field;
		}