use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class UnionGraph method forwardPropagate.
@Override
@SuppressWarnings("unchecked")
public Collection<Edge> forwardPropagate(CAATPredicate changedSource, Collection<? extends Derivable> added) {
if (changedSource == first || changedSource == second) {
ArrayList<Edge> newlyAdded = new ArrayList<>();
Collection<Edge> addedEdges = (Collection<Edge>) added;
for (Edge e : addedEdges) {
Edge edge = derive(e);
if (simpleGraph.add(edge)) {
newlyAdded.add(edge);
}
}
return newlyAdded;
} else {
return Collections.emptyList();
}
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class AcyclicityConstraint method reduceChordsAndNormalize.
private void reduceChordsAndNormalize(List<Edge> cycle) {
// Reduces chords by iteratively merging first and last edge if possible
// Note that edges in the middle should not have chords since
// we start with a shortest cycle rooted at some node <e>
// TODO: after the first merge, the two nodes of the merged edge
// both may allow further merging but we only iteratively merge one of the two.
boolean prog;
do {
if (cycle.size() == 1) {
// Self-cycles are not reducible
return;
}
prog = false;
Edge in = cycle.get(cycle.size() - 1);
Edge out = cycle.get(0);
Edge chord = constrainedGraph.get(new Edge(in.getFirst(), out.getSecond()));
if (chord != null) {
cycle.remove(cycle.size() - 1);
cycle.set(0, chord);
prog = true;
}
} while (prog);
// Normalize
int first = 0;
int minId = Integer.MAX_VALUE;
int counter = 0;
for (Edge e : cycle) {
if (e.getFirst() < minId) {
minId = e.getFirst();
first = counter;
}
counter++;
}
Collections.rotate(cycle, -first);
}
Aggregations