When a node has more than N successors/predecessors/neighbors then it must be removed,
(which results in a failure)
If it has N successors/predecessors/neighbors in the kernel then other incident edges
should be removed
766612
private void checkAtMost(int i) throws ContradictionException {
		ISet ker = target.getMandSet(g, i);
		ISet env = target.getPotSet(g, i);
		int size = ker.size();
		if (size > degrees[i]) {
			g.removeNode(i, this);
		} else if (size == degrees[i] && env.size() > size) {
			for (int other : env) {
				if (!ker.contains(other)) {
					target.remove(g, i, other, this);
				}
			}
		}
	}
74134
void inPlaceNodeRemove(int removeNodeCount) {
        // Prepare edge-update of nodes which are connected to deleted nodes
        int toMoveNodes = getNodes();
        int itemsToMove = 0;

        // sorted map when we access it via keyAt and valueAt - see below!
        final SparseIntIntArray oldToNewMap = new SparseIntIntArray(removeNodeCount);
        GHBitSet toRemoveSet = new GHBitSetImpl(removeNodeCount);
        removedNodes.copyTo(toRemoveSet);

        if (removeNodeCount > getNodes() / 2.0)
            LoggerFactory.getLogger(getClass()).warn("More than a half of the network should be removed!? "
                    + "Nodes:" + getNodes() + ", remove:" + removeNodeCount);

        EdgeExplorer delExplorer = createEdgeExplorer();
        // create map of old node ids pointing to new ids
        for (int removeNode = removedNodes.next(0);
             removeNode >= 0;
             removeNode = removedNodes.next(removeNode + 1)) {
            EdgeIterator delEdgesIter = delExplorer.setBaseNode(removeNode);
            while (delEdgesIter.next()) {
                toRemoveSet.add(delEdgesIter.getAdjNode());
            }

            toMoveNodes--;
            // move only nodes that are not removed
            for (; toMoveNodes >= 0; toMoveNodes--) {
                if (!removedNodes.contains(toMoveNodes))
                    break;
            }

            if (toMoveNodes >= removeNode)
                oldToNewMap.put(toMoveNodes, removeNode);

            itemsToMove++;
        }

        EdgeIterable adjNodesToDelIter = (EdgeIterable) createEdgeExplorer();
        // now similar process to disconnectEdges but only for specific nodes
        // all deleted nodes could be connected to existing. remove the connections
        for (int removeNode = toRemoveSet.next(0);
             removeNode >= 0;
             removeNode = toRemoveSet.next(removeNode + 1)) {
            // remove all edges connected to the deleted nodes
            adjNodesToDelIter.setBaseNode(removeNode);
            long prevPointer = EdgeIterator.NO_EDGE;
            while (adjNodesToDelIter.next()) {
                int nodeId = adjNodesToDelIter.getAdjNode();
                // already invalidated
                if (!EdgeAccess.isInvalidNodeB(nodeId) && removedNodes.contains(nodeId)) {
                    int edgeToRemove = adjNodesToDelIter.getEdge();
                    long edgeToRemovePointer = edgeAccess.toPointer(edgeToRemove);
                    edgeAccess.internalEdgeDisconnect(edgeToRemove, prevPointer, removeNode);
                    edgeAccess.invalidateEdge(edgeToRemovePointer);
                } else {
                    prevPointer = adjNodesToDelIter.edgePointer;
                }
            }
        }

        GHBitSet toMoveSet = new GHBitSetImpl(removeNodeCount * 3);
        EdgeExplorer movedEdgeExplorer = createEdgeExplorer();
        // marks connected nodes to rewrite the edges
        for (int i = 0; i < itemsToMove; i++) {
            int oldI = oldToNewMap.keyAt(i);
            EdgeIterator movedEdgeIter = movedEdgeExplorer.setBaseNode(oldI);
            while (movedEdgeIter.next()) {
                int nodeId = movedEdgeIter.getAdjNode();
                if (EdgeAccess.isInvalidNodeB(nodeId))
                    continue;

                if (removedNodes.contains(nodeId))
                    throw new IllegalStateException("shouldn't happen as the edge to the node "
                            + nodeId + " should be already deleted. " + oldI);

                toMoveSet.add(nodeId);
            }
        }

        // move nodes into deleted nodes
        for (int i = 0; i < itemsToMove; i++) {
            int oldI = oldToNewMap.keyAt(i);
            int newI = oldToNewMap.valueAt(i);
            long newOffset = (long) newI * nodeEntryBytes;
            long oldOffset = (long) oldI * nodeEntryBytes;
            for (long j = 0; j < nodeEntryBytes; j += 4) {
                nodes.setInt(newOffset + j, nodes.getInt(oldOffset + j));
            }
        }

        // *rewrites* all edges connected to moved nodes
        // go through all edges and pick the necessary <- this is easier to implement than
        // a more efficient (?) breadth-first search
        EdgeIterator iter = getAllEdges();
        while (iter.next()) {
            int nodeA = iter.getBaseNode();
            int nodeB = iter.getAdjNode();
            if (!toMoveSet.contains(nodeA) && !toMoveSet.contains(nodeB))
                continue;

            // now overwrite exiting edge with new node ids
            int updatedA = oldToNewMap.get(nodeA);
            if (updatedA < 0)
                updatedA = nodeA;

            int updatedB = oldToNewMap.get(nodeB);
            if (updatedB < 0)
                updatedB = nodeB;

            // no need to rewrite flags or other properties as they are independent of the node order unlike in <= 0.11
            int edgeId = iter.getEdge();
            long edgePointer = edgeAccess.toPointer(edgeId);
            int linkA = edgeAccess.getLinkA(edgePointer);
            int linkB = edgeAccess.getLinkB(edgePointer);
            edgeAccess.writeEdge(edgeId, updatedA, updatedB, linkA, linkB);
        }

        if (removeNodeCount >= nodeCount)
            throw new IllegalStateException("graph is empty after in-place removal but was " + removeNodeCount);

        // clear N_EDGE_REF
        initNodeRefs(((long) nodeCount - removeNodeCount) * nodeEntryBytes, (long) nodeCount * nodeEntryBytes);

        // we do not remove the invalid edges => edgeCount stays the same!
        nodeCount -= removeNodeCount;

        // health check
        if (isTestingEnabled()) {
            EdgeExplorer explorer = createEdgeExplorer();
            iter = getAllEdges();
            while (iter.next()) {
                int base = iter.getBaseNode();
                int adj = iter.getAdjNode();
                String str = iter.getEdge()
                        + ", r.contains(" + base + "):" + removedNodes.contains(base)
                        + ", r.contains(" + adj + "):" + removedNodes.contains(adj)
                        + ", tr.contains(" + base + "):" + toRemoveSet.contains(base)
                        + ", tr.contains(" + adj + "):" + toRemoveSet.contains(adj)
                        + ", base:" + base + ", adj:" + adj + ", nodeCount:" + nodeCount;
                if (adj >= nodeCount)
                    throw new RuntimeException("Adj.node problem with edge " + str);

                if (base >= nodeCount)
                    throw new RuntimeException("Base node problem with edge " + str);

                try {
                    explorer.setBaseNode(adj).toString();
                } catch (Exception ex) {
                    org.slf4j.LoggerFactory.getLogger(getClass()).error("adj:" + adj);
                }
                try {
                    explorer.setBaseNode(base).toString();
                } catch (Exception ex) {
                    org.slf4j.LoggerFactory.getLogger(getClass()).error("base:" + base);
                }
            }
            // access last node -> no error
            explorer.setBaseNode(nodeCount - 1).toString();
        }
        removedNodes = null;
    }
158237
def remove_filtered_nodes(graph, node_predicates=None):
    
    nodes = list(filter_nodes(graph, node_predicates=node_predicates))
    graph.remove_nodes_from(nodes)
1004493
def remove_isolated_nodes_op(graph):
    
    rv = graph.copy()
    nodes = list(nx.isolates(rv))
    rv.remove_nodes_from(nodes)
    return rv
1114599
private void removeNodeFromList(RepairQueueNode el) {
    // the head case
    //
    if (null == el.prev) {
      if (null != el.next) {
        this.head = el.next;
        this.head.prev = null;
        el=null;
      }
      else {
        // can't happen? yep. if there is only one element exists...
        this.head = null;
      }
    }
    // the tail case
    //
    else if (null == el.next) {
      if (null != el.prev) {
        el.prev.next = null;
      }
      else {
        // can't happen?
        throw new RuntimeException("Unrecognized situation here...");
      }
    }
    // all others
    //
    else {
      el.prev.next = el.next;
      el.next.prev = el.prev;
    }

  }
83434
def _flag_node_as_del_and_del_in_by_target(self, node_id):
        """"""
        self.nodes_deleted.append(node_id)
        etp = self._edge_by_target.get(node_id)
        if etp is not None:
            del self._edge_by_target[node_id]
647685
function removeEdge(u, v){
    if(edges[u]){
      edges[u] = adjacent(u).filter(function (_v){
        return _v !== v;
      });
    }
    return graph;
  }
610793
def _remove_layer_and_reconnect(self, layer):
        
        successors = self.get_successors(layer)
        predecessors = self.get_predecessors(layer)
        # remove layer's edges
        for succ in successors:
            self._remove_edge(layer, succ)
        for pred in predecessors:
            self._remove_edge(pred, layer)

        # connect predecessors and successors
        for pred in predecessors:
            for succ in successors:
                self._add_edge(pred, succ)

        # remove layer in the data structures
        self.layer_list.remove(layer)
        self.keras_layer_map.pop(layer)

        # re-assign input and output layers if layer happens to be an
        # input / output layer
        if layer in self.input_layers:
            idx = self.input_layers.index(layer)
            self.input_layers.pop(idx)
            for pred in predecessors:
                self.input_layers.insert(idx, pred)
                idx += 1
        if layer in self.output_layers:
            idx = self.output_layers.index(layer)
            self.output_layers.pop(idx)
            for succ in successors:
                self.output_layers.insert(idx, succ)
                idx += 1
8646
def del_big_nodes(self, grater_than=215):
        """"""
        G = self._graph
        it = G.nodes_iter()
        node_paths = []
        node_names = []
        del_nodes = []
        summe = 1
        count = 1
        for node in it:
            l = len(G[node])
            if l > grater_than:
                del_nodes.append(node)
                continue
            summe += l
            node_names.append(node)
            node_paths.append(l)
            count += 1
        for node in del_nodes:
            G.remove_node(node)
            if node > 1000000000:
                self.valid_user.pop(node)

        print("Nodes deleted: {}".format(len(del_nodes)))
657296
protected Node<K, V> unlinkAndUnionChildren(Node<K, V> n) {
        // disconnect children
        Node<K, V> child1 = n.o_c;
        if (child1 == null) {
            return null;
        }
        n.o_c = null;

        Node<K, V> child2 = child1.y_s;
        if (child2 == n) {
            child2 = null;
        } else {
            child2.y_s = null;
        }
        child1.y_s = null;

        if (comparator == null) {
            return union(child1, child2);
        } else {
            return unionWithComparator(child1, child2);
        }
    }
3132
public void removeEdge(N a, N b)
    {
        if(!containsBoth(a, b))
            return;
        nodes.get(a).getOutgoing().remove(b);
        nodes.get(b).getIncoming().remove(a);
    }
204311
def remove_nodes(self, indices):
        

        self.molecule.remove_sites(indices)
        self.graph.remove_nodes_from(indices)

        mapping = {}
        for correct, current in enumerate(sorted(self.graph.nodes)):
            mapping[current] = correct

        nx.relabel_nodes(self.graph, mapping, copy=False)
        self.set_node_attributes()
728546
private void removeNode(Node node)
	{
		result.remove(node);

		for (Edge edge : node.getUpstream())
		{
			result.remove(edge);
		}

		for (Edge edge : node.getDownstream())
		{
			result.remove(edge);
		}
	}
235090
void removeInternal(Node<K, V> node, boolean unlink) {
    if (unlink) {
      node.prev.next = node.next;
      node.next.prev = node.prev;
    }

    Node<K, V> left = node.left;
    Node<K, V> right = node.right;
    Node<K, V> originalParent = node.parent;
    if (left != null && right != null) {

      /*
       * To remove a node with both left and right subtrees, move an
       * adjacent node from one of those subtrees into this node's place.
       *
       * Removing the adjacent node may change this node's subtrees. This
       * node may no longer have two subtrees once the adjacent node is
       * gone!
       */

      Node<K, V> adjacent = (left.height > right.height) ? left.last() : right.first();
      removeInternal(adjacent, false); // takes care of rebalance and size--

      int leftHeight = 0;
      left = node.left;
      if (left != null) {
        leftHeight = left.height;
        adjacent.left = left;
        left.parent = adjacent;
        node.left = null;
      }

      int rightHeight = 0;
      right = node.right;
      if (right != null) {
        rightHeight = right.height;
        adjacent.right = right;
        right.parent = adjacent;
        node.right = null;
      }

      adjacent.height = Math.max(leftHeight, rightHeight) + 1;
      replaceInParent(node, adjacent);
      return;
    } else if (left != null) {
      replaceInParent(node, left);
      node.left = null;
    } else if (right != null) {
      replaceInParent(node, right);
      node.right = null;
    } else {
      replaceInParent(node, null);
    }

    rebalance(originalParent, false);
    size--;
    modCount++;
  }
1241131
static void removeSingleConnections( List<Node> cluster ) {
		List<Node> open = new ArrayList<>();
		List<Node> future = new ArrayList<>();

		open.addAll(cluster);

		while( !open.isEmpty() ) {
			for (int i = open.size()-1; i >= 0; i--) {
				Node n = open.get(i);

				if( n.connections.size == 1 ) {
					// clear it's connections and remove it from the cluster
					int index = findNode(n.which,cluster);
					cluster.remove(index);

					// Remove the reference to this node from its one connection
					int parent = findNode(n.connections.get(0),cluster);
					n.connections.reset();
					if( parent == -1 ) throw new RuntimeException("BUG!");
					Node p = cluster.get(parent);
					int edge = p.connections.indexOf(n.which);
					if( edge == -1 ) throw new RuntimeException("BUG!");
					p.connections.remove(edge);

					// if the parent now only has one connection
					if( p.connections.size == 1) {
						future.add(p);
					}
				}
			}
			open.clear();
			List<Node> tmp = open;
			open = future;
			future = tmp;
		}
	}
437271
public void removeNode(N node)
    {
        Pair<HashSet<N>, HashSet<N>> p = nodes.remove(node);
        if(p == null)
            return;
        //Outgoing edges we can ignore removint he node drops them. We need to avoid dangling incoming edges to this node we have removed
        HashSet<N> incomingNodes = p.getIncoming();
        for(N incomingNode : incomingNodes)
            nodes.get(incomingNode).getOutgoing().remove(node);
    }
624091
private final V finish_removal(BinTreeNode<K,V> node, BinTreeNode<K,V> prev,
				   int son, BinTreeNode<K,V> m) {
	if(m != null) { // set up the links for m
	    m.left  = node.left;
	    m.right = node.right;
	}
	if(prev == null)
	    root = m;
	else {
	    if(son == 0)
		prev.left = m;
	    else
		prev.right = m;
	}

	return node.value;
    }