/** * alternative for method getOutDegree() from class node. Finds the number of visible incident * edges. * * @param node * @return */ private int getOutVDegree(TableNodeItem node) { Iterator neighbors = node.neighbors(); TableNodeItem neighbor; TableEdgeItem edge; int outVDegree = 0; while (neighbors.hasNext()) { neighbor = (TableNodeItem) neighbors.next(); edge = (TableEdgeItem) (node.getGraph()).getEdge(node, neighbor); if (edge != null && edge.isVisible()) { outVDegree++; } } return outVDegree; }
/** * replaces method children() from class Node * * @param n * @return an iterator over neighbors connected to n by outgoing edges */ private Iterator<TableNodeItem> children(TableNodeItem n) { Iterator neighbors = n.neighbors(); TableNodeItem neighbor; TableEdgeItem nodeNeighborEdge; List<TableNodeItem> childrenList = new ArrayList<TableNodeItem>(); while (neighbors.hasNext()) { neighbor = (TableNodeItem) neighbors.next(); nodeNeighborEdge = (TableEdgeItem) (n.getGraph()).getEdge(neighbor, n); if (nodeNeighborEdge != null) { childrenList.add(neighbor); } } return childrenList.iterator(); }
/** * replaces method getFirstChild() from class Node * * @param node * @return the first neighbor connected to node by an outgoing, control flow ("CF") type edge */ private TableNodeItem getChild(TableNodeItem node) { TableNodeItem child = null; Iterator neighbors = node.neighbors(); TableNodeItem neighbor; Edge nodeNeighborEdge; while (neighbors.hasNext()) { neighbor = (TableNodeItem) neighbors.next(); nodeNeighborEdge = (node.getGraph()).getEdge(neighbor, node); if (nodeNeighborEdge != null) { if (nodeNeighborEdge.getString(TYPE).equals(CONTROL_FLOW)) { child = neighbor; break; } } } return child; }
/** * returns the first child of a "Step" type node * * @param node * @return the first neighbor connected to the node by an incoming, "Step" type edge */ public TableNodeItem getStepChild(TableNodeItem node) { TableNodeItem stepChild = null; Iterator neighbors = node.neighbors(); TableNodeItem neighbor; Edge nodeNeighborEdge; while (neighbors.hasNext()) { neighbor = (TableNodeItem) neighbors.next(); nodeNeighborEdge = (node.getGraph()).getEdge(neighbor, node); if (nodeNeighborEdge != null) { if (nodeNeighborEdge.getString(TYPE).equals(STEP)) { stepChild = neighbor; break; } } } return stepChild; }