congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TreeNode.setIndex
Code IndexAdd Tabnine to your IDE (free)

How to use
setIndex
method
in
phylo.tree.model.TreeNode

Best Java code snippets using phylo.tree.model.TreeNode.setIndex (Showing top 5 results out of 315)

origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Adds a node to the tree and refreshes its vertex. this is useful to add vertices that were in another tree before.
 */
public int addVertex(TreeNode n, final boolean refreshIndex) {
  if (refreshIndex)
    n.setIndex(-1);
  return addVertex(n);
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Clones this node.
 *
 * @return node the new node
 */
public TreeNode cloneNode() {
  TreeNode n = new TreeNode();
  n.setLabel(getLabel());
  n.setIndex(getIndex());
  return n;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

/**
 * Add subtree to existing tree, recursive iteration over the subtree to add
 *
 * @param tree    the target tree
 * @param parent  the parent node
 * @param newNode the current node to be added to the parent
 * @return node added node
 */
private TreeNode addSubtree(Tree tree, TreeNode parent, TreeNode newNode) {
  TreeNode nn = newNode.cloneNode();
  nn.setIndex(-1);
  tree.addVertex(nn);
  tree.addEdge(parent, nn);
  for (TreeNode child : newNode.children()) {
    addSubtree(tree, nn, child);
  }
  return nn;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

@SuppressWarnings("unchecked")
private void hangIn(TreeNode newParent, TreeNode oldParent, Tree tree) {
  for (TreeNode n : oldParent.children()) {
    TreeNode newNode = n.cloneNode();
    newNode.setIndex(-1);
    tree.addVertex(newNode);
    Edge edge = tree.addEdge(newParent, newNode);
    edge.setWeight(n.getDistanceToParent());
    hangIn(newNode, n, tree);
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Create a new {@link Tree} that represents the subtree of this tree rooted at the given
 * node. The returned tree is a new tree that contains clones of the {@link TreeNode}s of this tree.
 * The node copies are created using {@link TreeNode#cloneNode()} and are
 * new instances, so you will not have object equality ( n != n.cloneNode() ). Node equality using
 * {@link TreeNode#equals(Object)} will work at least for labeled nodes (because the labels are compared), but
 * for performance reasons we do not do deep checks.
 * <p>
 * If this tree does not contain the given node, null is returned.
 *
 * @param n the root node of the subtree
 * @return subtree rooted at the given node or null
 */
public Tree getSubtree(TreeNode n) {
  if (n == null) throw new NullPointerException();
  if (nodes.get(n.getIndex()) != n) {
    return null;
  }
  Tree r = new Tree();
  r.setName(getName());
  TreeNode root = n.cloneNode();
  root.setIndex(-1); // reset index
  r.addVertex(root);
  r.setRoot(root);
  hangIn(root, n, r);
  return r;
}
phylo.tree.modelTreeNodesetIndex

Popular methods of TreeNode

  • <init>
    Create a new node with given label
  • childCount
    Returns the number of children of this node.
  • depthFirstIterator
    Returns a depth first Iterable. This enables iterating the subtree rooted at this node in post order
  • getLabel
    The label of this node. If the label is not set, this looks for a label property TreeNodeProperties#
  • getParent
    Return the parent of this node.
  • isInnerNode
    Returns true if this is not a leaf.
  • isLeaf
    Returns true if this node is a leaf.
  • children
    Returns an Iterable over all children of this node. This allow using nodes in foreach loop: for(Tre
  • getChildren
    Get a list of all children of this node. It is helpful if one wants to iterate over all children and
  • getEdgeToParent
    Return the edge to the parent node or null.
  • getLevel
    Lazy and one time computation of the level of this node.
  • getDistanceToParent
    Returns the distance to the parent node. If the node has no parent (root node ) -1 is returned.
  • getLevel,
  • getDistanceToParent,
  • getLeaves,
  • setLabel,
  • cloneNode,
  • equalsNode,
  • getChildAt,
  • getGraph,
  • getIndex,
  • getPartition

Popular in Java

  • Creating JSON documents from java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now