org.deri.iris.api.graph
Interface IPredicateGraph

All Known Implementing Classes:
PredicateGraph

public interface IPredicateGraph

A graph to determine the dependencies of rules and predicates to each other.

$Id$

Version:
$Revision$
Author:
Richard P??ttler (richard dot poettler at deri dot org)

Method Summary
 void addRule(Collection<IRule> r)
          Adds a collection of rules to the graph.
 void addRule(IRule rule)
          Adds a rule to the graph.
 int countNegativesForCycle()
          Returns the number of negative Literals in the cycle.
 boolean detectCycles()
          Determines whether the rules are recursive.
 Set<LabeledEdge<IPredicate,Boolean>> findEdgesForCycle()
          Determines the edges contained in the cycle.
 Set<IPredicate> findVertexesForCycle()
          Determines the vertexes contained in the cycle.
 Set<IPredicate> getDepends(IPredicate p)
          Returns a set of predicates the given one depends on.
 Comparator<IPredicate> getPredicateComparator()
           Returns a compareator which compares two predicates depending on their dependencies of their rules.
 Comparator<IRule> getRuleComparator()
           Returs a comparator which compares two rules depending on their dependencies of each other.
 

Method Detail

addRule

void addRule(IRule rule)
Adds a rule to the graph.

Parameters:
rule - the rule to add
Throws:
NullPointerException - if the rule is null

detectCycles

boolean detectCycles()
Determines whether the rules are recursive.

Returns:
true if they are recursive, otherwise false

findVertexesForCycle

Set<IPredicate> findVertexesForCycle()
Determines the vertexes contained in the cycle.

Returns:
a Set containing all the vertexes

findEdgesForCycle

Set<LabeledEdge<IPredicate,Boolean>> findEdgesForCycle()
Determines the edges contained in the cycle.

Returns:
a Set containing all the vertexes

countNegativesForCycle

int countNegativesForCycle()
Returns the number of negative Literals in the cycle.

Returns:
the number of negative literals

addRule

void addRule(Collection<IRule> r)
Adds a collection of rules to the graph.

Parameters:
r - the collection of rules
Throws:
NullPointerException - if the collections is or contains null

getDepends

Set<IPredicate> getDepends(IPredicate p)
Returns a set of predicates the given one depends on.

Parameters:
p - predicate for which to check for dependencies
Returns:
the predicates the predicate depends on
Throws:
NullPointerException - if the predicate is null

getPredicateComparator

Comparator<IPredicate> getPredicateComparator()

Returns a compareator which compares two predicates depending on their dependencies of their rules.

If one of the compared predicate isn't in the graph, or there isn't a path from one predicate to the other 0 will be returned. If the first predicate depends on the second one, the first one will be determined to be bigger, and vice versa.

Returns:
the comparator

getRuleComparator

Comparator<IRule> getRuleComparator()

Returs a comparator which compares two rules depending on their dependencies of each other.

The rules will compared according to their headpredicates.

Returns:
the comparator
See Also:
getPredicateComparator()