/// <summary> Adds all the vertices and all the edges of the specified source digraph /// to the specified destination digraph, reversing all of the edges. /// /// <p> /// The behavior of this operation is undefined if any of the specified /// graphs is modified while operation is in progress. /// </p> /// /// </summary> /// <param name="destination">the graph to which vertices and edges are added. /// </param> /// <param name="source">the graph used as source for vertices and edges to add. /// </param> public static void addGraphReversed(DirectedGraph destination, DirectedGraph source) { destination.addAllVertices(source.vertexSet()); System.Collections.IEnumerator edgesIter = source.edgeSet().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 (edgesIter.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'" DirectedEdge edge = (DirectedEdge)edgesIter.Current; DirectedEdge reversedEdge = new DirectedEdge(edge.Target, edge.Source); destination.addEdge(reversedEdge); } }
/* * The subroutine of DFS. NOTE: the set is used to distinguish between 1st * and 2nd round of DFS. set == null: finished vertices are stored (1st * round). set != null: all vertices found will be saved in the set (2nd * round) */ private void dfsVisit(DirectedGraph graph, VertexData vertexData, SupportClass.SetSupport vertices) { System.Collections.ArrayList stack = new System.Collections.ArrayList(); stack.Add(vertexData); while (!(stack.Count == 0)) { VertexData data = (VertexData)SupportClass.StackSupport.Pop(stack); if (!data.m_discovered) { data.m_discovered = true; if (vertices != null) { vertices.Add(data.m_vertex); } // TODO: other way to identify when this vertex is finished!? stack.Add(new VertexData(this, data, true, true)); // follow all edges System.Collections.IEnumerator iter = graph.outgoingEdgesOf(data.m_vertex).GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (iter.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" DirectedEdge edge = (DirectedEdge)iter.Current; VertexData targetData = (VertexData)m_vertexToVertexData[edge.Target]; if (!targetData.m_discovered) { // the "recursion" stack.Add(targetData); } } } else if (data.m_finished) { if (vertices == null) { // see TODO above m_orderedVertices.Insert(0, data.m_vertex); } } } }
/// <summary> Adds all the vertices and all the edges of the specified source digraph /// to the specified destination digraph, reversing all of the edges. /// /// <p> /// The behavior of this operation is undefined if any of the specified /// graphs is modified while operation is in progress. /// </p> /// /// </summary> /// <param name="destination">the graph to which vertices and edges are added. /// </param> /// <param name="source">the graph used as source for vertices and edges to add. /// </param> public static void addGraphReversed(DirectedGraph destination, DirectedGraph source) { destination.addAllVertices(source.vertexSet()); System.Collections.IEnumerator edgesIter = source.edgeSet().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 (edgesIter.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'" DirectedEdge edge = (DirectedEdge) edgesIter.Current; DirectedEdge reversedEdge = new DirectedEdge(edge.Target, edge.Source); destination.addEdge(reversedEdge); } }