/** * Returns a copy of this with the given value removed. The given value does not have to be a set's root node. */ private static <V> UnionFind<V> copyAndRemove(UnionFind<V> unionFind, V element) { UnionFind<V> result = new UnionFind<>(); for (Set<V> partition : unionFind.getPartitions()) { Set<V> filteredPartition = new HashSet<>(partition); filteredPartition.remove(element); result.makeSet(filteredPartition); } return result; }
public IncSCCAlg(IGraphDataSource<V> graphDataSource) { if (graphDataSource instanceof IBiDirectionalGraphDataSource<?>) { gds = (IBiDirectionalGraphDataSource<V>) graphDataSource; } else { gds = new IBiDirectionalWrapper<V>(graphDataSource); } observers = CollectionsFactory.createObserverList(); sccs = new UnionFind<V>(); reducedGraph = new Graph<V>(); reducedGraphIndexer = new IBiDirectionalWrapper<V>(reducedGraph); countingListener = new CountingListener<V>(this); initalizeInternalDataStructures(); gds.attachObserver(this); }
List<Variable> unnamedRunningVariables = PatternLanguageHelper.getUnnamedRunningVariables(patternBody); variables.removeAll(unnamedRunningVariables); UnionFind<Variable> justPositiveUnionFindForVariables = new UnionFind<>(variables); UnionFind<Variable> generalUnionFindForVariables = new UnionFind<>(variables); boolean isSecondRunNeeded = false;
private UnionFind<Variable> calculateEqualVariables(PatternBody body) { UnionFind<Variable> unions = new UnionFind<>(body.getVariables()); TreeIterator<EObject> it = body.eAllContents(); while (it.hasNext()) { EObject obj = it.next(); if (obj instanceof CompareConstraint) { CompareConstraint constraint = (CompareConstraint) obj; if (constraint.getFeature() == CompareFeature.EQUALITY) { ValueReference left = constraint.getLeftOperand(); ValueReference right = constraint.getRightOperand(); if (left instanceof VariableReference && right instanceof VariableReference) { unions.union(((VariableReference) left).getVariable(), ((VariableReference) right).getVariable()); } } it.prune(); } else if (obj instanceof Constraint) { it.prune(); } } return unions; }