Search in sources :

Example 1 with MaterializedSubgraphView

use of com.dat3m.dartagnan.solver.caat.predicates.misc.MaterializedSubgraphView 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;
}
Also used : MaterializedSubgraphView(com.dat3m.dartagnan.solver.caat.predicates.misc.MaterializedSubgraphView) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)

Aggregations

MaterializedSubgraphView (com.dat3m.dartagnan.solver.caat.predicates.misc.MaterializedSubgraphView)1 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)1