use of fr.lirmm.graphik.graal.rulesetanalyser.util.PredicatePosition in project graal by graphik-team.
the class GraphPositionDependencies method initFiniteRank.
public void initFiniteRank() {
if (this.isFiniteRank == null) {
this.isFiniteRank = new TreeSet<PredicatePosition>();
StrongConnectivityInspector<PredicatePosition, DefaultEdge> sccInspector = new StrongConnectivityInspector<PredicatePosition, DefaultEdge>(graph);
List<Set<PredicatePosition>> sccList = sccInspector.stronglyConnectedSets();
for (Set<PredicatePosition> scc : sccList) {
boolean componentIsFiniteRank = true;
for (PredicatePosition p1 : scc) {
for (PredicatePosition p2 : scc) {
for (DefaultEdge edge : graph.getAllEdges(p1, p2)) {
if (edge instanceof SpecialEdge) {
componentIsFiniteRank = false;
}
}
}
}
// store information
if (componentIsFiniteRank) {
for (PredicatePosition p : scc) {
this.isFiniteRank.add(p);
}
}
}
}
}
use of fr.lirmm.graphik.graal.rulesetanalyser.util.PredicatePosition in project graal by graphik-team.
the class MarkedVariableSet method secondStep.
/**
* apply until a fixpoint is reached: for each rule Ri, if a marked variable
* v appears at position p[k] in its body, then for each rule Rj (including
* i = j) and for each variable x appearing at position p[k] in the head of
* Rj, mark each occurence of x in the body of Rj.
*/
private void secondStep() {
LinkedList<MarkedRule> mrList;
PredicatePosition mpos;
Term v;
while (!this.markedPosition.isEmpty()) {
mpos = this.markedPosition.poll();
mrList = this.map.get(mpos.predicate);
if (mrList != null) {
for (MarkedRule mr : mrList) {
CloseableIteratorWithoutException<Atom> it = mr.rule.getHead().iterator();
while (it.hasNext()) {
Atom a = it.next();
if (a.getPredicate().equals(mpos.predicate)) {
v = a.getTerm(mpos.position);
if (v.isVariable()) {
this.mark(v, mr);
}
}
}
}
}
}
}
Aggregations