private GraphConnections<N, V> newConnections() { return isDirected() ? DirectedGraphConnections.<N, V>of() : UndirectedGraphConnections.<N, V>of(); } }
private GraphConnections<N, V> newConnections() { return isDirected() ? DirectedGraphConnections.<N, V>of() : UndirectedGraphConnections.<N, V>of(); } }
private GraphConnections<N, V> newConnections() { return isDirected() ? DirectedGraphConnections.<N, V>of() : UndirectedGraphConnections.<N, V>of(); } }
@Override @CanIgnoreReturnValue public boolean removeNode(N node) { checkNotNull(node, "node"); GraphConnections<N, V> connections = nodeConnections.get(node); if (connections == null) { return false; } if (allowsSelfLoops()) { // Remove self-loop (if any) first, so we don't get CME while removing incident edges. if (connections.removeSuccessor(node) != null) { connections.removePredecessor(node); --edgeCount; } } for (N successor : connections.successors()) { nodeConnections.getWithoutCaching(successor).removePredecessor(node); --edgeCount; } if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal. for (N predecessor : connections.predecessors()) { checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null); --edgeCount; } } nodeConnections.remove(node); checkNonNegative(edgeCount); return true; }
@Override @CanIgnoreReturnValue public boolean removeNode(N node) { checkNotNull(node, "node"); GraphConnections<N, V> connections = nodeConnections.get(node); if (connections == null) { return false; } if (allowsSelfLoops()) { // Remove self-loop (if any) first, so we don't get CME while removing incident edges. if (connections.removeSuccessor(node) != null) { connections.removePredecessor(node); --edgeCount; } } for (N successor : connections.successors()) { nodeConnections.getWithoutCaching(successor).removePredecessor(node); --edgeCount; } if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal. for (N predecessor : connections.predecessors()) { checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null); --edgeCount; } } nodeConnections.remove(node); checkNonNegative(edgeCount); return true; }
@Override @CanIgnoreReturnValue public boolean removeNode(N node) { checkNotNull(node, "node"); GraphConnections<N, V> connections = nodeConnections.get(node); if (connections == null) { return false; } if (allowsSelfLoops()) { // Remove self-loop (if any) first, so we don't get CME while removing incident edges. if (connections.removeSuccessor(node) != null) { connections.removePredecessor(node); --edgeCount; } } for (N successor : connections.successors()) { nodeConnections.getWithoutCaching(successor).removePredecessor(node); --edgeCount; } if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal. for (N predecessor : connections.predecessors()) { checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null); --edgeCount; } } nodeConnections.remove(node); checkNonNegative(edgeCount); return true; }
private GraphConnections<N, V> newConnections() { return isDirected() ? DirectedGraphConnections.<N, V>of() : UndirectedGraphConnections.<N, V>of(); } }
private GraphConnections<N, V> newConnections() { return isDirected() ? DirectedGraphConnections.<N, V>of() : UndirectedGraphConnections.<N, V>of(); } }
@Override @CanIgnoreReturnValue public boolean removeNode(N node) { checkNotNull(node, "node"); GraphConnections<N, V> connections = nodeConnections.get(node); if (connections == null) { return false; } if (allowsSelfLoops()) { // Remove self-loop (if any) first, so we don't get CME while removing incident edges. if (connections.removeSuccessor(node) != null) { connections.removePredecessor(node); --edgeCount; } } for (N successor : connections.successors()) { nodeConnections.getWithoutCaching(successor).removePredecessor(node); --edgeCount; } if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal. for (N predecessor : connections.predecessors()) { checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null); --edgeCount; } } nodeConnections.remove(node); checkNonNegative(edgeCount); return true; }
@Override @CanIgnoreReturnValue public boolean removeNode(N node) { checkNotNull(node, "node"); GraphConnections<N, V> connections = nodeConnections.get(node); if (connections == null) { return false; } if (allowsSelfLoops()) { // Remove self-loop (if any) first, so we don't get CME while removing incident edges. if (connections.removeSuccessor(node) != null) { connections.removePredecessor(node); --edgeCount; } } for (N successor : connections.successors()) { nodeConnections.getWithoutCaching(successor).removePredecessor(node); --edgeCount; } if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal. for (N predecessor : connections.predecessors()) { checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null); --edgeCount; } } nodeConnections.remove(node); checkNonNegative(edgeCount); return true; }