Drop a network, while also cleaning up any edges that are no longer part of any network.
555825
def drop_network(self, network: Network) -> None:
        """"""
        # get the IDs of the edges that will be orphaned by deleting this network
        # FIXME: this list could be a problem if it becomes very large; possible optimization is a temporary table in DB
        edge_ids = [result.edge_id for result in self.query_singleton_edges_from_network(network)]

        # delete the network-to-node mappings for this network
        self.session.query(network_node).filter(network_node.c.network_id == network.id).delete(
            synchronize_session=False)

        # delete the edge-to-property mappings for the to-be-orphaned edges
        self.session.query(edge_property).filter(edge_property.c.edge_id.in_(edge_ids)).delete(
            synchronize_session=False)

        # delete the edge-to-annotation mappings for the to-be-orphaned edges
        self.session.query(edge_annotation).filter(edge_annotation.c.edge_id.in_(edge_ids)).delete(
            synchronize_session=False)

        # delete the edge-to-network mappings for this network
        self.session.query(network_edge).filter(network_edge.c.network_id == network.id).delete(
            synchronize_session=False)

        # delete the now-orphaned edges
        self.session.query(Edge).filter(Edge.id.in_(edge_ids)).delete(synchronize_session=False)

        # delete the network
        self.session.query(Network).filter(Network.id == network.id).delete(synchronize_session=False)

        # commit it!
        self.session.commit()
1087118
def cleanup(graph, subgraphs):
    
    for subgraph in subgraphs.values():
        update_node_helper(graph, subgraph)
        update_metadata(graph, subgraph)
100153
def del_node(self, node):
        
        if self.has_node(node):
            for e in self.node_links[node]:
                self.edge_links[e].remove(node)

            self.node_links.pop(node)
            self.graph.del_node((node,'n'))
1268245
def deleteNetwork(self, id, headers=None, query_params=None, content_type="application/json"):
        
        uri = self.client.base_url + "/network/"+id
        return self.client.delete(uri, None, headers, query_params, content_type)
712014
def clean(self):
        """"""
        connection = self._backend._get_connection()
        self._backend.clean(connection)
1028079
def _remove_network(network):
    '''
    
    '''
    ret = {'name': network['Name'],
           'changes': {},
           'result': False,
           'comment': ''}

    errors = []
    for cid in network['Containers']:
        try:
            cinfo = __salt__['docker.inspect_container'](cid)
        except CommandExecutionError:
            # Fall back to container ID
            cname = cid
        else:
            cname = cinfo.get('Name', '').lstrip('/')

        try:
            __salt__['docker.disconnect_container_from_network'](cid, network['Name'])
        except CommandExecutionError as exc:
            errors = \
                'Failed to disconnect container \'{0}\' : {1}'.format(
                    cname, exc
                )
        else:
            ret['changes'].setdefault('disconnected', []).append(cname)

    if errors:
        ret['comment'] = '\n'.join(errors)
        return ret

    try:
        __salt__['docker.remove_network'](network['Name'])
    except CommandExecutionError as exc:
        ret['comment'] = 'Failed to remove network: {0}'.format(exc)
    else:
        ret['changes']['removed'] = True
        ret['result'] = True
        ret['comment'] = 'Removed network \'{0}\''.format(network['Name'])

    return ret
250047
def remove_edges_from(self, ebunch):
        
        for e in ebunch:
            (u, v) = e[:2]
            if u in self.succ and v in self.succ[u]:
                del self.succ[u][v]
794979
def teardown(self):
        
        self.containers._teardown()
        self.networks._teardown()
        self.volumes._teardown()

        # We need to close the underlying APIClient explicitly to avoid
        # ResourceWarnings from unclosed HTTP connections.
        self._client.api.close()
1241273
async function dropAll(dgraphClient) {
    const op = new dgraph.Operation();
    op.setDropAll(true);
    await dgraphClient.alter(op);
}
657063
def cleanup(self):
        """"""
        for _id, shard in self._shards.items():
            if shard.get('isServer', False):
                Servers().remove(shard['_id'])
            if shard.get('isReplicaSet', False):
                ReplicaSets().remove(shard['_id'])

        for mongos in self._routers:
            Servers().remove(mongos)

        for config_id in self._configsvrs:
            self.configdb_singleton.remove(config_id)

        self._configsvrs = []
        self._routers = []
        self._shards = {}
1698
def cleanup(self):
        

        while self.inactive_timeout > 0:
            self.time = time.time()

            keys = []

            for key, client in self.clients.items.items():
                t = getattr(client, "active_at", 0)
                if t > 0 and self.time - t > self.inactive_timeout:
                    client.kwargs["link"].disconnect()
                    keys.append(key)

            for key in keys:
                self.log_debug("Removing client (inactive): %s" % key)
                del self.clients[key]

            time.sleep(1)
577850
def clean_up_network(network_id, **kwargs):
    
    user_id = kwargs.get('user_id')
    #check_perm(user_id, 'delete_network')
    try:
        log.debug("Querying Network %s", network_id)
        net_i = db.DBSession.query(Network).filter(Network.id == network_id).\
        options(noload('scenarios')).options(noload('nodes')).options(noload('links')).options(noload('resourcegroups')).options(joinedload_all('types.templatetype.template')).one()
        net_i.attributes

        #Define the basic resource queries
        node_qry = db.DBSession.query(Node).filter(Node.network_id==network_id).filter(Node.status=='X').all()

        link_qry = db.DBSession.query(Link).filter(Link.network_id==network_id).filter(Link.status=='X').all()

        group_qry = db.DBSession.query(ResourceGroup).filter(ResourceGroup.network_id==network_id).filter(ResourceGroup.status=='X').all()

        scenario_qry = db.DBSession.query(Scenario).filter(Scenario.network_id==network_id).filter(Scenario.status=='X').all()


        for n in node_qry:
            db.DBSession.delete(n)
        for l in link_qry:
            db.DBSession.delete(l)
        for g in group_qry:
            db.DBSession.delete(g)
        for s in scenario_qry:
            db.DBSession.delete(s)

    except NoResultFound:
        raise ResourceNotFoundError("Network %s not found"%(network_id))
    db.DBSession.flush()
    return 'OK'
558071
def remove_network(self, net_id):
        
        url = self._url("/networks/{0}", net_id)
        res = self._delete(url)
        self._raise_for_status(res)
372689
def cleanup(self):
        
        if self.transport:
            self.transport.close()
            self.transport = None
        if self.task:
            self.task.cancel()
            self.task = None
197153
def drop():
    
    # Ensure the connection is up
    _State.connection()
    _State.table.drop(checkfirst=True)
    _State.metadata.remove(_State.table)
    _State.table = None
    _State.new_transaction()
709178
def drop(manager: Manager, network_id: Optional[int], yes):
    """"""
    if network_id:
        manager.drop_network_by_id(network_id)

    elif yes or click.confirm('Drop all networks?'):
        manager.drop_networks()
503192
function remove(connection, connections) {
  for (var i = 0; i < connections.length; i++) {
    if (connections[i] === connection) {
      connections.splice(i, 1);
      return true;
    }
  }
}