private static void runUDFS(final Graph g, Integer n, LinkedHashSet pre) { Queue q = new LinkedList(); Node nd; Integer nodeRow; Integer nodeNumber; Edge edg; Node nd2; q.add(new Integer(n.intValue())); while (!q.isEmpty()) { nodeRow = new Integer(((Integer) q.poll()).intValue()); if (!pre.contains(nodeRow)) { nd = g.getNode(nodeRow.intValue()); pre.add(nodeRow); for (Iterator it = nd.edges(); it.hasNext(); ) { edg = (Edge) it.next(); nd2 = edg.getTargetNode(); nodeNumber = new Integer(nd2.getRow()); if (!pre.contains(nodeNumber)) q.add(nodeNumber); nd2 = edg.getSourceNode(); nodeNumber = new Integer(nd2.getRow()); if (!pre.contains(nodeNumber)) q.add(nodeNumber); } } } nodeRow = null; nodeNumber = null; q = null; edg = null; nd2 = null; }
@Before public void setUp() { m_vis = new Visualization(); m_t = TableTest.getTestCaseTable(); m_g = GraphTest.getTestCaseGraph(); m_t0 = m_t.getTuple(0); m_n0 = m_g.getNode(0); VisualTable vt = (VisualTable) m_vis.add("t", m_t); VisualGraph vg = (VisualGraph) m_vis.add("g", m_g); m_vt0 = vt.getItem(0); m_vn0 = (NodeItem) vg.getNode(0); TupleSet ts = m_vis.getFocusGroup(Visualization.FOCUS_ITEMS); ts.addTuple(m_vt0); ts.addTuple(m_vn0); }
private static void runDDFS(final Graph g, Integer n, LinkedHashSet nodeSet, boolean isPreOrder) { boolean done = false; Node nd; Node nd2; Integer nodeRow; Integer nodeNumber; Stack nodeStack = new Stack(); nodeStack.add(new Integer(n.intValue())); while (!nodeStack.isEmpty()) { nodeRow = (Integer) nodeStack.peek(); nd = g.getNode(nodeRow.intValue()); if (!nodeSet.contains(nodeRow)) { if (isPreOrder) nodeSet.add(nodeRow); nodeSet.add(nodeRow); } done = true; for (Iterator it = nd.outNeighbors(); it.hasNext(); ) { nd2 = ((Node) it.next()); nodeNumber = new Integer(nd2.getRow()); if (!nodeSet.contains(nodeNumber)) { nodeStack.add(nodeNumber); done = false; break; } } if (done) { if (!isPreOrder) nodeSet.add(nodeRow); nodeStack.pop(); } } nodeStack = null; nd = null; nd2 = null; nodeRow = null; nodeNumber = null; }
private Node getNode(int no) { Node node = graph.getNode(no); return node; }