public void removeNode(V node) { graph.removeVertex(node); }
public void removeNode(V node) { graph.removeVertex(node); }
@Override public synchronized boolean removeService(@Nonnull T service) { checkNotNull(service); log.debug("removing service"); return graph.removeVertex(service); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public void expand(Forest tree, Forest subTree) { Object parent = null; Object edge = null; if(tree.getPredecessorCount(subTree) > 0) { parent = tree.getPredecessors(subTree).iterator().next(); edge = tree.getInEdges(subTree).iterator().next(); } tree.removeVertex(subTree); TreeUtils.addSubTree(tree, subTree, parent, edge); } }
/** * Useful for immutable vertices, this method replaced the current vertex with a new vertex. To do so, it has to deep copy to a subgraph, and then copy * back, so not very efficient. This method is made necessary by Jung's approach to maintaining the integrity of the map - so far I have not found a way * to move an edge from one vertex to another without the associated vertices being deleted. https://github.com/davidsowerby/krail/issues/397 * * @param currentVertex the vertex to be replaced * @param newVertex the vertex to replace it with */ public void replaceNode(@Nonnull V currentVertex, @Nonnull V newVertex) { checkNotNull(currentVertex); checkNotNull(newVertex); V parentVertex = getParent(currentVertex); BasicForest<V> subGraph = subGraph(currentVertex, newVertex); graph.removeVertex(currentVertex); addChild(parentVertex, newVertex); mergeSubGraph(subGraph, parentVertex); }
/** * Useful for immutable vertices, this method replaced the current vertex with a new vertex. To do so, it has to deep copy to a subgraph, and then copy * back, so not very efficient. This method is made necessary by Jung's approach to maintaining the integrity of the map - so far I have not found a way * to move an edge from one vertex to another without the associated vertices being deleted. https://github.com/davidsowerby/krail/issues/397 * * @param currentVertex the vertex to be replaced * @param newVertex the vertex to replace it with */ public void replaceNode(V currentVertex, V newVertex) { checkNotNull(currentVertex); checkNotNull(newVertex); V parentVertex = getParent(currentVertex); BasicForest<V> subGraph = subGraph(currentVertex, newVertex); graph.removeVertex(currentVertex); addChild(parentVertex, newVertex); mergeSubGraph(subGraph, parentVertex); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public void collapse(Layout layout, Forest tree, Object subRoot) throws InstantiationException, IllegalAccessException { // get a sub tree from subRoot Forest subTree = TreeUtils.getSubTree(tree, subRoot); Object parent = null; Object edge = null; if(tree.getPredecessorCount(subRoot) > 0) { parent = tree.getPredecessors(subRoot).iterator().next(); edge = tree.getInEdges(subRoot).iterator().next(); } tree.removeVertex(subRoot); if(parent != null) { tree.addEdge(edge, parent, subTree); } else { tree.addVertex(subTree); } layout.setLocation(subTree, (Point2D)layout.apply(subRoot)); }