public static Graph reverseGraph(final Graph g) { Graph g2 = g; for (Iterator it = g.edges(); it.hasNext(); ) { Edge e = (Edge) it.next(); int edgeRow = e.getRow(); e = g2.getEdge(edgeRow); int newTarget = e.getSourceNode().getRow(); int newSource = e.getTargetNode().getRow(); e.set(0, new Integer(newSource)); e.set(1, new Integer(newTarget)); } return g2; }
public SelfLoopsParallelEdges(final Graph g) { HashSet selfLoops = new HashSet(); HashSet parallelEdges = new HashSet(); HashMap edges = new HashMap(); boolean directed = g.isDirected(); Edge edg; for (Iterator it = g.edges(); it.hasNext(); ) { edg = (Edge) it.next(); this.addEdge(edg, directed, selfLoops, parallelEdges, edges); } selfLoopInfo = this.calculateSelfLoops(selfLoops); parallelEdgeInfo = this.calculateParallelEdges(parallelEdges, edges); selfLoops = null; edges = null; parallelEdges = null; edg = null; }
/** @see prefuse.data.Node#edges() */ public Iterator edges() { return m_graph.edges(this); }