Exemplo n.º 1
0
  /**
   * sets invisible nodes with visible edges connected to them visible these nodes exist because the
   * setNodesAndEdgesVisible(...) method does not follow data flow ("DF") edges
   *
   * @param graph
   */
  private void setIsolatedNodesVisible(Graph graph) {

    Iterator graphNodes = graph.nodes();
    TableNodeItem node;

    while (graphNodes.hasNext()) {
      node = (TableNodeItem) graphNodes.next();

      if (!node.isVisible()) {
        Iterator incidentEdges = node.edges();
        int visibleEdges = 0;

        while (incidentEdges.hasNext()) {
          TableEdgeItem edge = (TableEdgeItem) incidentEdges.next();
          if (edge.isVisible()) {
            visibleEdges++;
          }
        }
        if (visibleEdges != 0) {
          node.setVisible(true);
          Iterator edges = node.edges();
          while (edges.hasNext()) {
            TableEdgeItem edgeItem = (TableEdgeItem) (edges.next());
            if (!edgeItem.getSourceItem().getString(TYPE).equals(STEP)
                && !edgeItem.getTargetItem().getString(TYPE).equals(STEP)) {
              edgeItem.setVisible(true);
            }
          }
        }
      }
    }
  }
Exemplo n.º 2
0
 private Table populateTable(Table t, Graph g) {
   for (final Iterator it = g.nodes(); it.hasNext(); ) {
     final Node n = (Node) it.next();
     t.addRow();
     for (int i = 0; i < n.getColumnCount(); i++) {
       t.set(t.getRowCount() - 1, i, n.get(i));
     }
     t.set(t.getRowCount() - 1, UNIQUE_INDEX_COLUMN_NAME, new Integer(t.getRowCount()));
   }
   return t;
 }
Exemplo n.º 3
0
  public List extractWeakComponentClusters(final Graph grph) {
    List clusters = new ArrayList();

    HashSet seenNodes = new HashSet();
    for (Iterator it = grph.nodes(); it.hasNext(); ) {
      Node n = (Node) it.next();
      Integer i = new Integer(n.getRow());
      if (!seenNodes.contains(i)) {

        LinkedHashSet cluster = GraphSearchAlgorithms.undirectedDepthFirstSearch(grph, i);
        seenNodes.addAll(cluster);
        clusters.add(cluster);
      }
    }
    return clusters;
  }
Exemplo n.º 4
0
  public static LinkedHashSet undirectedDepthFirstSearch(final Graph g, Integer n) {

    LinkedHashSet nodeSet = new LinkedHashSet();
    Integer nodeNumber;
    if (n == null) { // If no node number is presented, search the whole graph.
      for (Iterator it = g.nodes(); it.hasNext(); ) {
        nodeNumber = new Integer(((Node) it.next()).getRow());
        runUDFS(g, nodeNumber, nodeSet);
      }
    } else { // Otherwise, just search the specific node.
      nodeNumber = new Integer(n.intValue());
      runUDFS(g, nodeNumber, nodeSet);
    }

    return nodeSet;
  }
Exemplo n.º 5
0
  /**
   * sets nodes with no visible edges connected to them (isolated nodes) invisible these nodes exist
   * because the setNodesAndEdgesInvisible(...) method does not follow data flow ("DF") edges
   *
   * @param graph
   */
  private void setIsolatedNodesInvisible(Graph graph) {

    Iterator graphNodes = graph.nodes();
    TableNodeItem node;
    boolean rootDrawn = false;
    while (graphNodes.hasNext()) {
      node = (TableNodeItem) graphNodes.next();
      if (node.isVisible() && getOutVDegree(node) == 0 && rootDrawn) {
        node.setVisible(false);
        Iterator incidentEdges = node.edges();
        while (incidentEdges.hasNext()) {
          ((TableEdgeItem) incidentEdges.next()).setVisible(false);
        }
      }
      rootDrawn = true;
    }
  }
Exemplo n.º 6
0
 public static LinkedHashSet directedDepthFirstSearch(
     final Graph g, Integer n, boolean getPreOrder, boolean isReverse) {
   LinkedHashSet nodeSet = new LinkedHashSet();
   Graph g2 = g;
   if (isReverse) {
     if (isReverse) {
       g2 = reverseGraph(g);
     }
   }
   if (n == null) {
     for (Iterator it = g2.nodes(); it.hasNext(); ) {
       Integer nodeNumber = new Integer(((Node) it.next()).getRow());
       runDDFS(g2, nodeNumber, nodeSet, getPreOrder);
     }
   } else {
     runDDFS(g2, n, nodeSet, getPreOrder);
   }
   return nodeSet;
 }