Package org.jgrapht.traverse

Examples of org.jgrapht.traverse.BreadthFirstIterator


    }
  }

  void setStateRecursive(RootedTree tree, PhyloNode base, int state)
  {
    BreadthFirstIterator bfi = new BreadthFirstIterator(tree, base);
    while (bfi.hasNext())
    {
      PhyloNode n = (PhyloNode) bfi.next();
      n.setState(state);
    }
  }
View Full Code Here


  }

  public int getMaxDepthToLeaf(Object vertex)
  {
    int maxDepth = 0;
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      Object o = bfi.next();
      if (isLeaf(o))
      {
        int curDepth = getDepthToVertex(o, vertex);
        if (curDepth > maxDepth)
          maxDepth = curDepth;
View Full Code Here

  }

  public double getMaxHeightToLeaf(Object vertex)
  {
    double maxHeight = 0;
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      Object o = bfi.next();
      if (isLeaf(o))
      {
        double curHeight = getHeightToRoot(o);
        if (curHeight > maxHeight)
          maxHeight = curHeight;
View Full Code Here

  }

  private List getEnclosedVertices(Object vertex)
  {
    ArrayList l = new ArrayList();
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      l.add(bfi.next());
    }
    return l;
  }
View Full Code Here

  }

  private List getEnclosedLeaves(Object vertex)
  {
    ArrayList l = new ArrayList();
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      Object o = bfi.next();
      if (isLeaf(o))
        l.add(o);
    }
    return l;
  }
View Full Code Here

    // System.out.println(this);
    // STEP 3: Re-orient all edges, branching out from the root edge.
    //
    // Iterate over an undirected version of this graph, so we can "go
    // against the grain" when we need to.
    BreadthFirstIterator bfi = new BreadthFirstIterator(Graphs
        .undirectedGraph(this), root);
    // Toss all the nodes into a linked list.
    LinkedList linked = new LinkedList();
    while (bfi.hasNext())
    {
      linked.addLast(bfi.next());
    }
    // Now, go through the list of nodes, re-orienting edges as needed.
    // Set the root node as the first parent in our algorithm.
    HashMap seen = new HashMap();
    Integer stupidInt = new Integer(1);
View Full Code Here

   *
   * @param vertex
   */
  public void reverseSubtree(Object vertex)
  {
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      Object o = bfi.next();
      flipChildren(o);
    }
  }
View Full Code Here

   *
   * @param vertex
   */
  public void ladderizeSubtree(Object vertex)
  {
    BreadthFirstIterator bfi = new BreadthFirstIterator(this, vertex);
    while (bfi.hasNext())
    {
      Object o = bfi.next();
      sorting.put(o, FORWARD);
    }
  }
View Full Code Here

    /*
     * Now, to recreate the newick file's node sorting. We previously recorded the "first" child
     * node for each parent node, which we'll now use to determine whether we want to sort that
     * node in forward or reverse.
     */
    BreadthFirstIterator dfi = new BreadthFirstIterator(tree, tree.getRoot());
    while (dfi.hasNext()) {
      Object p = dfi.next();
      if (!tree.isLeaf(p)) {
        tree.sorting.put(p, RootedTree.REVERSE);
        List l = tree.getChildrenOf(p);
        if (l.get(0) != firstChildren.get(p)) tree.sorting.put(p, RootedTree.FORWARD);
      }
View Full Code Here

    /*
     * Now, to recreate the newick file's node sorting. We previously recorded the "first" child
     * node for each parent node, which we'll now use to determine whether we want to sort that
     * node in forward or reverse.
     */
    BreadthFirstIterator dfi = new BreadthFirstIterator(tree, tree.getRoot());
    while (dfi.hasNext()) {
      Object p = dfi.next();
      if (!tree.isLeaf(p)) {
        tree.sorting.put(p, RootedTree.REVERSE);
        List l = tree.getChildrenOf(p);
        if (l.get(0) != firstChildren.get(p)) tree.sorting.put(p, RootedTree.FORWARD);
      }
View Full Code Here

TOP

Related Classes of org.jgrapht.traverse.BreadthFirstIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.