use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class AcyclicityConstraint method getViolations.
@Override
public List<List<Edge>> getViolations() {
if (violatingSccs.isEmpty()) {
return Collections.emptyList();
}
List<List<Edge>> cycles = new ArrayList<>();
// (3) remove chords and normalize cycle order (starting from element with smallest id)
for (Set<Integer> scc : violatingSccs) {
MaterializedSubgraphView subgraph = new MaterializedSubgraphView(constrainedGraph, scc);
Set<Integer> nodes = new HashSet<>(Sets.intersection(scc, markedNodes));
while (!nodes.isEmpty()) {
int e = nodes.stream().findAny().get();
List<Edge> cycle = PathAlgorithm.findShortestPath(subgraph, e, e);
cycle = new ArrayList<>(cycle);
cycle.forEach(edge -> nodes.remove(edge.getFirst()));
// TODO: Most cycles have chords, so a specialized algorithm that avoids
// chords altogether would be great
reduceChordsAndNormalize(cycle);
if (!cycles.contains(cycle)) {
cycles.add(cycle);
}
}
}
return cycles;
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class CoherenceGraph method edgeIterator.
@Override
public Iterator<Edge> edgeIterator(int id, EdgeDirection dir) {
EventData e = getEvent(id);
if (!e.isWrite()) {
return Collections.emptyIterator();
}
com.google.common.base.Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
return Iterators.transform(getCoSuccessorList(e, dir).iterator(), mapping);
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class CoherenceGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
if (!e.isWrite()) {
return Stream.empty();
}
Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
return getCoSuccessorList(e, dir).stream().map(mapping);
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class InternalGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
return threadEventsMap.get(e.getThread()).stream().map(edgeMapping);
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class LocationGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
if (!e.isMemoryEvent()) {
return Stream.empty();
}
Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
return addrEventsMap.get(e.getAccessedAddress()).stream().map(edgeMapping);
}
Aggregations