Removes unused edges from the old collection, compared to the new collection
181086
private List<AtlasEdge> removeUnusedEntries(AtlasVertex instanceVertex, String edgeLabel,
                                             Collection<AtlasEdge> currentEntries,
                                             Collection<AtlasEdge> newEntries,
                                             IDataType entryType, AttributeInfo attributeInfo) throws AtlasException {
        if (currentEntries != null && !currentEntries.isEmpty()) {
            LOG.debug("Removing unused entries from the old collection");
            if (entryType.getTypeCategory() == TypeCategory.STRUCT
                    || entryType.getTypeCategory() == TypeCategory.CLASS) {

                //Remove the edges for (current edges - new edges)
                List<AtlasEdge> cloneElements = new ArrayList<>(currentEntries);
                cloneElements.removeAll(newEntries);
                List<AtlasEdge> additionalElements = new ArrayList<>();

                if (LOG.isDebugEnabled()) {
                    LOG.debug("Removing unused entries from the old collection - {}", cloneElements);
                }

                if (!cloneElements.isEmpty()) {
                    for (AtlasEdge edge : cloneElements) {
                        boolean deleted = deleteHandler.deleteEdgeReference(edge, entryType.getTypeCategory(),
                                attributeInfo.isComposite, true);
                        if (!deleted) {
                            additionalElements.add(edge);
                        }
                    }
                }
                return additionalElements;
            }
        }
        return new ArrayList<>();
    }
350338
def __remove_obsolete_metadata(self):
        
        clean = {}
        for key, _ in self._source_file_names.items():
            if key in self._pystratum_metadata:
                clean[key] = self._pystratum_metadata[key]

        self._pystratum_metadata = clean
193229
def remove_unused_grid_rc(self):
        """"""

        if 'columns' in self['layout']:
            ckeys = tuple(self['layout']['columns'].keys())
            for key in ckeys:
                value = int(key)
                if value > self.max_col:
                    del self['layout']['columns'][key]
        if 'rows' in self['layout']:
            rkeys = tuple(self['layout']['rows'].keys())
            for key in rkeys:
                value = int(key)
                if value > self.max_row:
                    del self['layout']['rows'][key]
1238269
private Map<String, Object> removeUnusedMapEntries(AtlasAttribute attribute, AtlasVertex vertex, String propertyName,
                                                       Map<String, Object> currentMap, Map<String, Object> newMap)
                                                                             throws AtlasException, AtlasBaseException {
        AtlasMapType        mapType       = (AtlasMapType) attribute.getAttributeType();
        Map<String, Object> additionalMap = new HashMap<>();

        for (String currentKey : currentMap.keySet()) {
            boolean shouldDeleteKey = !newMap.containsKey(currentKey);

            if (AtlasGraphUtilsV1.isReference(mapType.getValueType())) {
                //Delete the edge reference if its not part of new edges created/updated
                AtlasEdge currentEdge = (AtlasEdge)currentMap.get(currentKey);

                if (!newMap.values().contains(currentEdge)) {
                    boolean deleted = deleteHandler.deleteEdgeReference(currentEdge, mapType.getValueType().getTypeCategory(), attribute.isOwnedRef(), true);

                    if (!deleted) {
                        additionalMap.put(currentKey, currentEdge);
                        shouldDeleteKey = false;
                    }
                }
            }

            if (shouldDeleteKey) {
                String propertyNameForKey = GraphHelper.getQualifiedNameForMapKey(propertyName, GraphHelper.encodePropertyKey(currentKey));
                GraphHelper.setProperty(vertex, propertyNameForKey, null);
            }
        }

        return additionalMap;
    }
158916
function deleteView(id, viewID) {
  return updateItem(id, item => {
    const pos = item.views.findIndex(e => e.viewID === viewID);
    item.views.splice(pos, 1);
    // prune orphaned collections
    const bin = {};
    item.dataset.forEach(e => { bin[e.collectionID] = 0; });
    item.views.forEach(view => {
      ['rows', 'items', 'nodes', 'edges']
        .filter(e => view.hasOwnProperty(e))
        .forEach(e => { bin[view[e]] += 1; });
    });
    Object.entries(bin).forEach(entry => {
      if (!entry[1]) {
        const i = item.dataset.findIndex(e => e.collectionID === entry[0]);
        item.dataset.splice(i, 1);
      }
    });
  });
}
123632
def remove_edge_from_heap(self, segment_ids):
        """"""
        self._initialize_heap()
        key = normalize_edge(segment_ids)
        if key in self.edge_map:
            self.edge_map[key][0] = None
            self.num_valid_edges -= 1
874077
def filterStack(self, filters):
        
        visited, removes, orphans = filter_stack(self.graph, self, filters)

        for last_good, tail in orphans:
            self.graph.add_edge(last_good, tail, edge_data='orphan')

        for node in removes:
            self.graph.hide_node(node)

        return len(visited)-1, len(removes), len(orphans)
986916
def _remove_unused_nodes(self):
        

        # Namespace shortcuts.
        nodes, wf_remove_node = self.nodes, self.workflow.remove_node
        add_visited, succ = self._visited.add, self.workflow.succ

        # Remove unused function and sub-dispatcher nodes.
        for n in (set(self._wf_pred) - set(self._visited)):
            node_type = nodes[n]['type']  # Node type.

            if node_type == 'data':
                continue  # Skip data node.

            if node_type == 'dispatcher' and succ[n]:
                add_visited(n)  # Add to visited nodes.
                i = self.index + nodes[n]['index']
                self.sub_sol[i]._remove_unused_nodes()
                continue  # Skip sub-dispatcher node with outputs.

            wf_remove_node(n)
1100705
private Map<String, Object> removeUnusedMapEntries(
            AtlasVertex instanceVertex, String propertyName,
            Map<String, Object> currentMap,
            Map<String, Object> newMap, IDataType elementType,
            AttributeInfo attributeInfo)
                    throws AtlasException {

        Map<String, Object> additionalMap = new HashMap<>();
        for (String currentKey : currentMap.keySet()) {

            boolean shouldDeleteKey = !newMap.containsKey(currentKey);
            if (GraphHelper.isReference(elementType)) {

                //Delete the edge reference if its not part of new edges created/updated
                AtlasEdge currentEdge = (AtlasEdge)currentMap.get(currentKey);

                if (!newMap.values().contains(currentEdge)) {

                    boolean deleted =
                            deleteHandler.deleteEdgeReference(currentEdge, elementType.getTypeCategory(), attributeInfo.isComposite, true);
                    if (!deleted) {
                        additionalMap.put(currentKey, currentEdge);
                        shouldDeleteKey = false;
                    }
                }
            }

            if (shouldDeleteKey) {
                String propertyNameForKey = GraphHelper.getQualifiedNameForMapKey(propertyName, currentKey);
                GraphHelper.setProperty(instanceVertex, propertyNameForKey, null);
            }
        }
        return additionalMap;
    }
949564
private void cleanup() {
		CacheEntry oldest = null;
		_count = 0;

		// Cleanup obsolete entries and find the oldest
		for (Map.Entry<String, CacheEntry> e : _cache.entrySet()) {
			String key = e.getKey();
			CacheEntry entry = e.getValue();
			// Remove obsolete entry
			if (entry.isExpired()) {
				_cache.remove(key);
			}
			// Count the remaining entry
			else {
				_count++;
				if (oldest == null || oldest.getExpiration() > entry.getExpiration())
					oldest = entry;
			}
		}

		// Remove the oldest if cache size exceeded maximum
		if (_count > _maxSize && oldest != null) {
			_cache.remove(oldest.getKey());
			_count--;
		}
	}
49512
private void clean(HudsonCollector collector, List<HudsonJob> existingJobs) {
        Set<ObjectId> uniqueIDs = new HashSet<>();
        for (com.capitalone.dashboard.model.Component comp : dbComponentRepository
                .findAll()) {

            if (CollectionUtils.isEmpty(comp.getCollectorItems())) continue;

            List<CollectorItem> itemList = comp.getCollectorItems().get(CollectorType.Build);

            if (CollectionUtils.isEmpty(itemList)) continue;

            for (CollectorItem ci : itemList) {
                if (collector.getId().equals(ci.getCollectorId())) {
                    uniqueIDs.add(ci.getId());
                }
            }
        }
        List<HudsonJob> stateChangeJobList = new ArrayList<>();
        for (HudsonJob job : existingJobs) {
            if ((job.isEnabled() && !uniqueIDs.contains(job.getId())) ||  // if it was enabled but not on a dashboard
                    (!job.isEnabled() && uniqueIDs.contains(job.getId()))) { // OR it was disabled and now on a dashboard
                job.setEnabled(uniqueIDs.contains(job.getId()));
                stateChangeJobList.add(job);
            }
        }
        if (!CollectionUtils.isEmpty(stateChangeJobList)) {
            hudsonJobRepository.save(stateChangeJobList);
        }
    }
1296468
def transitively_reduce(self):
        
        removals = set()

        for from_node, neighbors in self._edges.items():
            childpairs = \
                [(c1, c2) for c1 in neighbors for c2 in neighbors if c1 != c2]

            for child1, child2 in childpairs:
                if self.has_path(child1, child2) \
                   and not self.has_path(child1, from_node):
                    removals.add((from_node, child2))

        for edge in removals:
            self.remove_edge(edge[0], edge[1])
1158540
def strip(self, inplace=False):
        
        if not inplace:
            t = self.copy()
        else:
            t = self
        for e in t._tree.preorder_edge_iter():
            e.length = None
        t._dirty = True
        return t
1310407
def restore_all_edges(self):
        
        for edge in self.hidden_edges.keys():
            try:
                self.restore_edge(edge)
            except GraphError:
                pass
1248075
function() {

		var old_uid = this._data_uids.pop(),
			old_value = this._data_values.pop(),
			old_name = this._data_names.pop(),
			count = this._count - 1;

		this._setLength(count);

		this._fire('items_removed', {
			uids: [old_uid],
			values: [old_value],
			names: [old_name]
		});

		this._fire('collection_changed');

		return old_value;
	}
257027
def remove_unused_links(self, used):
        
        unused = []

        self._execute("SELECT * FROM {}".format(self.LINK_STATE_TABLE))
        for row in self.cursor:
            relpath, inode, mtime = row
            inode = self._from_sqlite(inode)
            path = os.path.join(self.root_dir, relpath)

            if path in used:
                continue

            if not os.path.exists(path):
                continue

            actual_inode = get_inode(path)
            actual_mtime, _ = get_mtime_and_size(path)

            if inode == actual_inode and mtime == actual_mtime:
                logger.debug("Removing '{}' as unused link.".format(path))
                remove(path)
                unused.append(relpath)

        for relpath in unused:
            cmd = 'DELETE FROM {} WHERE path = "{}"'
            self._execute(cmd.format(self.LINK_STATE_TABLE, relpath))
1372510
def clear(self):
        
        # self.graph = nx.Graph()
        self.graph.clear()
        self.data.clear()
        self.descriptors.clear()
        self.size2d = None
        self.rings = None
        self.scaffolds = None
        self.isolated = None