public TreeNode nextElement() { Edge e = (Edge) edges.next(); return (TreeNode) e.getTarget(); }
public TreeNode next() { Edge e = edges.next(); return (TreeNode) e.getTarget(); }
public int indegree(EdgeType type) { if (!type.directed) return 0; int sum = 0; List<E> l = adjList.get(type); for (E e : l) { if (e.getTarget() == this) sum++; } return sum; }
public MultiNode next() { return it.next().getTarget(); }
/** * Returns the child at position i * * @param i the child position * @return node the child at i */ public TreeNode getChildAt(int i) { if (edges == null || edges.size() <= 0 || edges.size() < i) return null; return edges.get(i).getTarget(); }
/** * returns true if this node is connected to the given edge */ public boolean containsEdge(E e) { if (e == null) return false; return e.getSource().equals(this) || e.getTarget().equals(this); }
public int indegree() { int sum = 0; for (EdgeType type : adjList.keySet()) { if (!type.isDirected()) continue; List<E> l = adjList.get(type); for (E e : l) { if (e.getTarget() == this) sum++; } } return sum; }
public boolean equals(Object o) { if (o == null) return false; if (o instanceof Edge) { //if both edges are of type 'undirected', it doesn't matter what is source and what target if (this.getType().equals(EdgeType.UNDIRECTED) && ((Edge) o).getType().equals(EdgeType.UNDIRECTED)) { return ((Edge) o).getSource().equals(source) && ((Edge) o).getTarget().equals(target) || ((Edge) o).getSource().equals(target) && ((Edge) o).getTarget().equals(source); } else { return ((Edge) o).getSource().equals(source) && ((Edge) o).getTarget().equals(target); } } return false; }
/** * Clears all edges and esures that edges are also removed from source or target nodes. */ public void clear() { // remove incoming edges for (Edge<MultiNode> e : incomingEdges.values()) { e.getSource().removeOutgoingEdge(e); } // remove outgoing Edges for (List<Edge<MultiNode>> l : outgoingEdges.values()) { for (Edge<MultiNode> edge : l) { edge.getTarget().removeIncomingEdge(edge); } } incomingEdges.clear(); outgoingEdges.clear(); }
public E addEdge(E e) { if (e.getSource().getIndex() < 0 || e.getTarget().getIndex() < 0) { throw new RuntimeException("One of the nodes connected by the new edge has a negative index, which means it is not associated to a graph !!!"); } e.getSource().addEdge(e); e.getTarget().addEdge(e); return e; }
public void removeEdge(E e) { if ( getVertex(e.getSource().getIndex()) == e.getSource() && getVertex(e.getTarget().getIndex()) == e.getTarget()) { e.getSource().removeEdge(e); e.getTarget().removeEdge(e); } else { throw new RuntimeException("Edge connects Vertices that are not contained in this graph!"); } }
/** * Adds the edge as outgoing edge to the edges source and as incoming edge * to the edges target vertex. * * @param e the edge * @return the edge */ public Edge<MultiNode> addEdge(Edge<MultiNode> e) { e.getSource().addOutgoingEdge(e); e.getTarget().addIncomingEdge(e); return e; }
/** * removes the edge by calling <code> getSource().removeEdge()</code> and * <code>getTarget().removeEdge()</code> on the given edge. * * @param e */ protected void removeEdge(Edge<MultiNode> e) { e.getSource().removeEdge(e); e.getTarget().removeEdge(e); }
/** * Clears the node. Removes all edges and null references. */ @SuppressWarnings("unchecked") public void clear() { if (incompingEdge != null) { incompingEdge.getSource().removeEdge(incompingEdge); incompingEdge = null; } if (edges != null) { for (Edge out : edges) { out.getTarget().removeEdge(out); } edges.clear(); } }
/** * Add an edge to this node. */ @SuppressWarnings("unchecked") public void addEdge(Edge e) { if (e.getSource() == this) { if (getEdge(e.getTarget()) == null) { edges.add(e); /* Fix #145 - we have to reset the level of all nodes below this one */ for (TreeNode node : this.depthFirstIterator()) { node.level = -1; } } } else { incompingEdge = e; level = -1; } }
public void removeEdge(E e) { removeEdge(e.getSource(), e.getTarget(), e.getType()); }
public static void reorderingBootstrapLabelsForRooting(Edge<TreeNode> edgeToReroot) { TreeNode outGroup = edgeToReroot.getTarget(); String startingLabel; //reordering inner labels for bootstrap Values if (outGroup.isInnerNode()) { startingLabel = outGroup.getLabel(); } else { startingLabel = edgeToReroot.getSource().getLabel(); } if (startingLabel != null) { moveUP(edgeToReroot, startingLabel); } }
TreeUtils.rerootToOutgroup(rootedModel, edgeToReroot.getTarget());
rerootToOutgroup(tree, edgeToReroot.getTarget(), weightTOChild);