edu.cs.ai.kreator.logic
Class ClauseNetwork

java.lang.Object
  extended by edu.cs.ai.kreator.logic.ClauseNetwork
All Implemented Interfaces:
java.lang.Iterable<ClauseNetworkNode>, java.util.Collection<ClauseNetworkNode>

public class ClauseNetwork
extends java.lang.Object
implements java.util.Collection<ClauseNetworkNode>

A clause network represents the dependencies between a set of clauses. For any two clauses c1 and c2 such that head(c1) in body(c2) there is a directed edge from c1 to c2.

This class is used when generating data for BLPs.

Author:
Matthias Thimm

Constructor Summary
ClauseNetwork()
          Creates a new empty network.
 
Method Summary
 boolean add(ClauseNetworkNode e)
           
 boolean addAll(java.util.Collection<? extends ClauseNetworkNode> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 boolean containsIntersectingClause(Clause clause)
          Checks whether there is a node in this network with clause "c" such that there is one literal in "c" (either head or body) that also appears in the given clause (either in the head or in the body).
 java.util.Set<Literal> evidenceData()
          Computes the evidence data of this network, i.e.
 Pair<ClauseNetworkNode,ClauseNetworkNode> getCombinableClauses()
          Checks whether there are at least two nodes in this network which's clauses share the same head and returns this pair if existing.
 java.util.Set<ClauseNetworkNode> getLeafs()
          Returns the set of leafs of this network.
 java.util.Set<ClauseNetworkNode> getRoots()
          Returns the set of roots of this network.
 boolean isEmpty()
           
 java.util.Iterator<ClauseNetworkNode> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean removeDownwardsRecursively(ClauseNetworkNode node)
          Removes the given clause and all its descendents.
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

ClauseNetwork

public ClauseNetwork()
Creates a new empty network.

Method Detail

add

public boolean add(ClauseNetworkNode e)
Specified by:
add in interface java.util.Collection<ClauseNetworkNode>

containsIntersectingClause

public boolean containsIntersectingClause(Clause clause)
Checks whether there is a node in this network with clause "c" such that there is one literal in "c" (either head or body) that also appears in the given clause (either in the head or in the body). Furthermore the clauses must have equal structure and just differ in their instantiations.

Parameters:
clause - a clause
Returns:
"true" if there is an intersecting clause.

getCombinableClauses

public Pair<ClauseNetworkNode,ClauseNetworkNode> getCombinableClauses()
Checks whether there are at least two nodes in this network which's clauses share the same head and returns this pair if existing.

Returns:
a pair of combinable nodes if existing or "null" otherwise

getRoots

public java.util.Set<ClauseNetworkNode> getRoots()
Returns the set of roots of this network.

Returns:
the set of roots of this network.

getLeafs

public java.util.Set<ClauseNetworkNode> getLeafs()
Returns the set of leafs of this network.

Returns:
the set of leafs of this network.

evidenceData

public java.util.Set<Literal> evidenceData()
Computes the evidence data of this network, i.e. all literals that appear in at least one body of a clause but not in a head of another clause;

Returns:
a set of literals.

addAll

public boolean addAll(java.util.Collection<? extends ClauseNetworkNode> c)
Specified by:
addAll in interface java.util.Collection<ClauseNetworkNode>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<ClauseNetworkNode>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<ClauseNetworkNode>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<ClauseNetworkNode>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<ClauseNetworkNode>

iterator

public java.util.Iterator<ClauseNetworkNode> iterator()
Specified by:
iterator in interface java.lang.Iterable<ClauseNetworkNode>
Specified by:
iterator in interface java.util.Collection<ClauseNetworkNode>

removeDownwardsRecursively

public boolean removeDownwardsRecursively(ClauseNetworkNode node)
Removes the given clause and all its descendents.

Parameters:
clause - the clause
Returns:
"true" if this operation modified this object.

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<ClauseNetworkNode>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<ClauseNetworkNode>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<ClauseNetworkNode>

size

public int size()
Specified by:
size in interface java.util.Collection<ClauseNetworkNode>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<ClauseNetworkNode>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<ClauseNetworkNode>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object