/** * If the given tuple is a Node or Edge in this graph, remove it. * @see prefuse.data.tuple.TupleSet#removeTuple(prefuse.data.Tuple) */ public boolean removeTuple(Tuple t) { // TODO: check underlying table tuples as well? if ( t instanceof Node ) { return removeNode((Node)t); } else if ( t instanceof Edge ) { return removeEdge((Edge)t); } else { throw new IllegalArgumentException( "Input tuple must be part of this graph"); } }
/** * Remove an edge from the graph. * @param e the Edge to remove from the graph * @return true if the edge was successfully removed, false if the * edge was not found in this graph */ public boolean removeEdge(Edge e) { edgeCheck(e, true); return removeEdge(e.getRow()); }
/** * Remove a node from the graph, also removing all incident edges. * @param node the node id (node table row number) of the node to remove * @return true if the node was successfully removed, false if the * node id was not found or was not valid */ public boolean removeNode(int node) { Table nodeTable = getNodeTable(); if ( nodeTable.isValidRow(node) ) { int id = getInDegree(node); if ( id > 0 ) { int[] links = (int[])m_links.get(node, INLINKS); for ( int i=id; --i>=0; ) removeEdge(links[i]); } int od = getOutDegree(node); if ( od > 0 ) { int[] links = (int[])m_links.get(node, OUTLINKS); for ( int i=od; --i>=0; ) removeEdge(links[i]); } } return nodeTable.removeRow(node); }
/** * Removes an edge. * @param edge edge to remove * @return true if removed */ public boolean removeEdge(Edge edge) { try { boolean removed = this.graph.removeEdge(edge.getRow()); if (removed) { fireNetworkEvent(edge.getRow(), edge.getRow(), 0, NetworkListener.DELETE_EDGE); } return removed; } catch (Exception e) { throw new ObviousRuntimeException(e); } }