Source:
<code>private void setIdsToRemoveWithNewExtensions(IStorageUtilityIndexed<Case> caseStorage, Vector<String> owners) { <START> DAG<String, int[], String> g = new DAG<String, int[], String>(); <END> Vector<CaseIndex> indexHolder = new Vector<CaseIndex>(); for (IStorageIterator<Case> i = caseStorage.iterate(); i.hasMore(); ) { Case c = i.nextRecord(); boolean owned = true; if (owners != null) { owned = owners.contains(c.getUserId()); } for (CaseIndex index : c.getIndices()) { CaseIndex toReplace = null; boolean skip = false; for (CaseIndex existing : indexHolder) { if (existing.getTarget().equals(index.getTarget())) { if (existing.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION) && !index.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION)) { toReplace = existing; } else { skip = true; } break; } } if (toReplace != null) { indexHolder.removeElement(toReplace); } if (!skip) { indexHolder.addElement(index); } } int nodeStatus = 0; if(owned) { nodeStatus |= STATUS_OWNED; } if(!c.isClosed()) { nodeStatus |= STATUS_OPEN; } if(owned && !c.isClosed()) { nodeStatus |= STATUS_RELEVANT; } g.addNode(c.getCaseId(), new int[]{nodeStatus, c.getID()}); for (CaseIndex index : indexHolder) { g.setEdge(c.getCaseId(), index.getTarget(), index.getRelationship()); } indexHolder.removeAllElements(); } markRelevant(g); markAvailable(g); markLive(g); for (Enumeration<int[]> iterator = g.getNodes(); iterator.hasMoreElements(); ) { int[] node = (int[])iterator.nextElement(); if (!is(node, STATUS_ALIVE)) { idsToRemove.addElement(Integer.valueOf(node[1])); } } }</code><technical_language>g a descriptive variable name. Also, stored in edge data of graph</technical_language>

Target:
private void setIdsToRemoveWithNewExtensions(IStorageUtilityIndexed<Case> caseStorage, Vector<String> owners) { DAG<String, int[], String> graph = new DAG<String, int[], String>(); Vector<CaseIndex> indexHolder = new Vector<CaseIndex>(); for (IStorageIterator<Case> i = caseStorage.iterate(); i.hasMore(); ) { Case c = i.nextRecord(); boolean owned = true; if (owners != null) { owned = owners.contains(c.getUserId()); } for (CaseIndex index : c.getIndices()) { CaseIndex toReplace = null; boolean skip = false; for (CaseIndex existing : indexHolder) { if (existing.getTarget().equals(index.getTarget())) { if (existing.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION) && !index.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION)) { toReplace = existing; } else { skip = true; } break; } } if (toReplace != null) { indexHolder.removeElement(toReplace); } if (!skip) { indexHolder.addElement(index); } } int nodeStatus = 0; if (owned) { nodeStatus |= STATUS_OWNED; } if (!c.isClosed()) { nodeStatus |= STATUS_OPEN; } if (owned && !c.isClosed()) { nodeStatus |= STATUS_RELEVANT; } graph.addNode(c.getCaseId(), new int[]{nodeStatus, c.getID()}); for (CaseIndex index : indexHolder) { graph.setEdge(c.getCaseId(), index.getTarget(), index.getRelationship()); } indexHolder.removeAllElements(); } propogateRelevance(graph); propogateAvailabile(graph); propogateLive(graph); for (Enumeration iterator = graph.getNodes(); iterator.hasMoreElements(); ) { int[] node = (int[])iterator.nextElement(); if (!caseStatusIs(node[0], STATUS_ALIVE)) { idsToRemove.addElement(Integer.valueOf(node[1])); } } }