Nodes that have only a single connection to one other node are disconnected since they are likely to be noise.
This is done recursively
5191
void disconnectSingleConnections() {

		List<SquareNode> open = new ArrayList<>();
		List<SquareNode> open2 = new ArrayList<>();

		for (int i = 0; i < nodes.size(); i++) {
			SquareNode n = nodes.get(i);
			checkDisconnectSingleEdge(open, n);
		}


		while( !open.isEmpty() ) {
			for (int i = 0; i < open.size(); i++) {
				SquareNode n = open.get(i);
				checkDisconnectSingleEdge(open2, n);

				open.clear();
				List<SquareNode> tmp = open;
				open = open2;
				open2 = tmp;
			}
		}
	}
1238788
function removeChildren(node) {
    node = node.lastChild;
    while (node) {
      var next = node.previousSibling;
      recollectNodeTree(node, true);
      node = next;
    }
  }
1308283
function deleteNode(record: RecordProxy, nodeID: DataID): void {
  const {EDGES, NODE} = RelayConnectionInterface.get();

  const edges = record.getLinkedRecords(EDGES);
  if (!edges) {
    return;
  }
  let nextEdges;
  for (let ii = 0; ii < edges.length; ii++) {
    const edge = edges[ii];
    const node = edge && edge.getLinkedRecord(NODE);
    if (node != null && node.getDataID() === nodeID) {
      if (nextEdges === undefined) {
        nextEdges = edges.slice(0, ii);
      }
    } else if (nextEdges !== undefined) {
      nextEdges.push(edge);
    }
  }
  if (nextEdges !== undefined) {
    record.setLinkedRecords(nextEdges, EDGES);
  }
}
131588
def disconnect(self):
        
        all_conns = chain(
            self._available_connections.values(),
            self._in_use_connections.values(),
        )

        for node_connections in all_conns:
            for connection in node_connections:
                connection.disconnect()
610749
def disconnect(self):
        
        if not self._connected:
            return

        log.info("Session: %s, Tree: %s - Disconnecting from Tree Connect"
                 % (self.session.username, self.share_name))

        req = SMB2TreeDisconnect()
        log.info("Session: %s, Tree: %s - Sending Tree Disconnect message"
                 % (self.session.username, self.share_name))
        log.debug(str(req))
        request = self.session.connection.send(req,
                                               sid=self.session.session_id,
                                               tid=self.tree_connect_id)

        log.info("Session: %s, Tree: %s - Receiving Tree Disconnect response"
                 % (self.session.username, self.share_name))
        res = self.session.connection.receive(request)
        res_disconnect = SMB2TreeDisconnect()
        res_disconnect.unpack(res['data'].get_value())
        log.debug(str(res_disconnect))
        self._connected = False
        del self.session.tree_connect_table[self.tree_connect_id]
3067
private void sweep() {
        for (Node p = head, s, n; p != null && (s = p.next) != null; ) {
            if (!s.isMatched())
                // Unmatched nodes are never self-linked
                p = s;
            else if ((n = s.next) == null) // trailing node is pinned
                break;
            else if (UNLINKED == n)    // stale
                // No need to also check for p == s, since that implies s == n
                p = head;
            else
                p.casNext(s, n);
        }
    }
1047844
def suppress_deg_one_node(self, to_par_edge, nd_id, to_child_edge):
        """"""
        # circumvent the node with nd_id
        to_child_edge_id = to_child_edge['@id']
        par = to_par_edge['@source']
        self._edge_by_source[par][to_child_edge_id] = to_child_edge
        to_child_edge['@source'] = par
        # make it a tip...
        del self._edge_by_source[nd_id]
        # delete it
        self._del_tip(nd_id)
309071
def disconnect(self, node):
        
        rel = _rel_helper(lhs='a', rhs='b', ident='r', **self.definition)
        q = "MATCH (a), (b) WHERE id(a)={self} and id(b)={them} " \
            "MATCH " + rel + " DELETE r"
        self.source.cypher(q, {'them': node.id})
341191
void disconnectEdgeFromCluster_(int edge, int cluster) {
		int next = getNextEdge(edge, cluster);
		assert (getPrevEdge(next, cluster) == edge);
		int prev = getPrevEdge(edge, cluster);
		assert (getNextEdge(prev, cluster) == edge);
		int first_edge = getClusterFirstEdge(cluster);
		if (next != edge) {
			setNextEdge_(prev, cluster, next);
			setPrevEdge_(next, cluster, prev);
			if (first_edge == edge)
				setClusterFirstEdge_(cluster, next);
		} else
			setClusterFirstEdge_(cluster, -1);
	}
716272
def disconnect(self):
        ''''''
        with self._mutex:
            if not self.ports:
                raise exceptions.NotConnectedError
            # Some of the connection participants may not be in the tree,
            # causing the port search in self.ports to return ('Unknown', None)
            # for those participants. Search the list to find the first
            # participant that is in the tree (there must be at least one).
            p = self.ports[0][1]
            ii = 1
            while not p and ii < len(self.ports):
                p = self.ports[ii][1]
                ii += 1
            if not p:
                raise exceptions.UnknownConnectionOwnerError
            p.object.disconnect(self.id)
1083384
private void signalDisconnected() {
        if (alternate != null) {
            LOGGER.info("Disconnected from Node {} ({})",
                system(hostname.nameAndAddress()), system(alternate.nameAndAddress()));
        } else {
            LOGGER.info("Disconnected from Node {}", system(hostname.nameAndAddress()));
        }
        if (eventBus != null && eventBus.hasSubscribers()) {
            eventBus.publish(new NodeDisconnectedEvent(hostname));
        }
    }
875720
function () {
					oNodeForContext.nodeState.removed = false;
					var iNodeStateFound = that._aRemoved.indexOf(oNodeForContext);
					if (iNodeStateFound != -1) {
						that._aRemoved.splice(iNodeStateFound, 1);
					}
					// clear cache to make sure findNode etc. don't deliver wrong nodes (index is shifted due to adding)
					this._aNodeCache = [];
					that._cleanTreeStateMaps();
					that._fireChange({reason: ChangeReason.Add});
				}
1025028
public  void markNodeOffline(@NonNull Node node) {
        synchronized (node) {
            node.status(NodeStatus.OFFLINE);

            for (val n : node.getDownstreamNodes())
                remapNode(n);
        }
    }
667629
def disconnect_all(self):
        ''''''
        with self._mutex:
            for conn in self.connections:
                self.object.disconnect(conn.id)
            self.reparse_connections()
1301972
synchronized SmbTreeHandleImpl ensureTreeConnected () throws CIFSException {
        if ( this.treeHandle == null || !this.treeHandle.isConnected() ) {
            if ( this.treeHandle != null && this.transportContext.getConfig().isStrictResourceLifecycle() ) {
                this.treeHandle.release();
            }
            this.treeHandle = this.treeConnection.connectWrapException(this.fileLocator);
            this.treeHandle.ensureDFSResolved();
            if ( this.transportContext.getConfig().isStrictResourceLifecycle() ) {
                // one extra share to keep the tree alive
                return this.treeHandle.acquire();
            }
            return this.treeHandle;
        }
        return this.treeHandle.acquire();
    }
952105
function() {
      var self = this;

      self._drain();

      // Find the first inactive node to recycle.
      for (var i=0; i<self._sounds.length; i++) {
        if (self._sounds[i]._ended) {
          return self._sounds[i].reset();
        }
      }

      // If no inactive node was found, create a new one.
      return new Sound(self);
    }
765681
def delete(node)
      unless @nodes.key?(node.key)
        raise NoSuchNodeError.new(node.key)
      end

      (node.edges(:out) + node.edges(:in)).each do |edge|
        edge.from.disconnect_via(edge)
        edge.to.disconnect_via(edge)
      end

      @nodes.delete(node.key)
    end