org.dllearner.algorithms.el
Class ELDescriptionNode

java.lang.Object
  extended by org.dllearner.algorithms.el.ELDescriptionNode

public class ELDescriptionNode
extends Object

Represents an EL description tree, which corresponds to a description in the EL description logic. Note that an EL description tree can be a subtree of another EL description tree. In general, an EL description tree is a tree where the node label is a set of named classes and the edges are labelled with a property. In the documentation below "this node" refers to the root node of this EL description (sub-)tree. One tree cannot be reused, i.e. used as subtree in several description trees, as some of the associated variables (level, simulation) depend on the overall tree.

Author:
Jens Lehmann

Constructor Summary
ELDescriptionNode(ELDescriptionNode parentNode, ObjectProperty parentProperty, NamedClass... label)
           
ELDescriptionNode(ELDescriptionNode parentNode, ObjectProperty parentProperty, Set<NamedClass> label)
           
ELDescriptionNode(ELDescriptionTree tree)
          Constructs an EL description tree with empty root label.
ELDescriptionNode(ELDescriptionTree tree, NamedClass... label)
           
ELDescriptionNode(ELDescriptionTree tree, TreeSet<NamedClass> label)
          Constructs an EL description tree given its root label.
 
Method Summary
 int computeLevel()
          Traverses the tree until the root node and counts how many edges are traversed.
 void extendLabel(NamedClass newClass)
          Adds an entry to the node label.
 int[] getCurrentPosition()
          Gets a list describing the position of this node within the tree.
 List<ELDescriptionEdge> getEdges()
          Gets the edges of this node.
 Set<ELDescriptionNode> getIn()
           
 Set<ELDescriptionNode> getInSC1()
           
 Set<ELDescriptionNode> getInSC2()
           
 NavigableSet<NamedClass> getLabel()
          Gets the label of this node.
 int getLevel()
          Gets the level (distance from root) of this node.
 Set<ELDescriptionNode> getOut()
           
 Set<ELDescriptionNode> getOutSC1()
           
 Set<ELDescriptionNode> getOutSC2()
           
 ELDescriptionNode getParent()
           
 ELDescriptionEdge getParentEdge()
           
 ELDescriptionNode getRoot()
          Traverses the EL description tree upwards until it finds the root and returns it.
 ELDescriptionTree getTree()
           
 boolean isRoot()
          Checks whether this node has a parent.
 void refineEdge(int edgeNumber, ObjectProperty op)
           
 void replaceInLabel(NamedClass oldClass, NamedClass newClass)
          Replaces an entry in the node label.
 String toDescriptionString()
           
 String toSimulationString()
           
 String toSimulationString(Map<ELDescriptionNode,String> nodeNames)
           
 String toString()
           
static String toString(Set<ELDescriptionNode> nodes, Map<ELDescriptionNode,String> nodeNames)
          A convenience method (for debugging purposes) to get a comma separated list of nodes, where the nodes are given names (to make them readable).
 Description transformToDescription()
          This method transform the tree to an EL description.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ELDescriptionNode

public ELDescriptionNode(ELDescriptionTree tree)
Constructs an EL description tree with empty root label.


ELDescriptionNode

public ELDescriptionNode(ELDescriptionTree tree,
                         NamedClass... label)

ELDescriptionNode

public ELDescriptionNode(ELDescriptionTree tree,
                         TreeSet<NamedClass> label)
Constructs an EL description tree given its root label.

Parameters:
label - Label of the root node.

ELDescriptionNode

public ELDescriptionNode(ELDescriptionNode parentNode,
                         ObjectProperty parentProperty,
                         NamedClass... label)

ELDescriptionNode

public ELDescriptionNode(ELDescriptionNode parentNode,
                         ObjectProperty parentProperty,
                         Set<NamedClass> label)
Method Detail

isRoot

public boolean isRoot()
Checks whether this node has a parent. If the parent link is null, the node is considered to be a root node.

Returns:
True of this is the root node and false otherwise.

getRoot

public ELDescriptionNode getRoot()
Traverses the EL description tree upwards until it finds the root and returns it.

Returns:
The root node of this EL description tree.

computeLevel

public int computeLevel()
Traverses the tree until the root node and counts how many edges are traversed. If this node does not have a parent, zero is returned. This method is used for checking the integrity of the tree in unit tests. Use getLevel() to get the level of the tree.

Returns:
The level of this node (or more specifically the root node of this subtree) within the overall EL description tree.

transformToDescription

public Description transformToDescription()
This method transform the tree to an EL description. The node labels are transformed to an Intersection of NamedClass. Each edge is transformed to an ObjectSomeRestriction, where the property is the edge label and the child description the subtree the edge points to. Edges are also added to the intersection. If the intersection is empty, Thing is returned.

Returns:
The description corresponding to this EL description tree.

getCurrentPosition

public int[] getCurrentPosition()
Gets a list describing the position of this node within the tree. If the list is e.g. [2,5,1], then the node can be reached by picking the second child of the root node, then picking the 5th child of this node and finally selecting the first child of the previous node.

Returns:
The position number of this node within the tree as described above.

replaceInLabel

public void replaceInLabel(NamedClass oldClass,
                           NamedClass newClass)
Replaces an entry in the node label.

Parameters:
oldClass - Class to remove from label.
newClass - Class to add to label.

extendLabel

public void extendLabel(NamedClass newClass)
Adds an entry to the node label.

Parameters:
newClass - Class to add to label.

refineEdge

public void refineEdge(int edgeNumber,
                       ObjectProperty op)

getLabel

public NavigableSet<NamedClass> getLabel()
Gets the label of this node. Do not modify the returned object, but use the provided methods instead!

Returns:
The label of root node of this subtree.

getEdges

public List<ELDescriptionEdge> getEdges()
Gets the edges of this node. Do not modify the returned object, but use the provided methods instead!

Returns:
The outgoing edges of this subtree.

getLevel

public int getLevel()
Gets the level (distance from root) of this node. The root node has level 1.

Returns:
The level of the (root node of) this subtree in the overall tree.

toString

public String toString()
Overrides:
toString in class Object

toDescriptionString

public String toDescriptionString()

toSimulationString

public String toSimulationString()

toString

public static String toString(Set<ELDescriptionNode> nodes,
                              Map<ELDescriptionNode,String> nodeNames)
A convenience method (for debugging purposes) to get a comma separated list of nodes, where the nodes are given names (to make them readable).

Parameters:
nodes - The node objects.
nodeNames - A mapping to node names.
Returns:
A comma separated list of the node names.

toSimulationString

public String toSimulationString(Map<ELDescriptionNode,String> nodeNames)

getParent

public ELDescriptionNode getParent()

getParentEdge

public ELDescriptionEdge getParentEdge()

getIn

public Set<ELDescriptionNode> getIn()
Returns:
the in

getInSC1

public Set<ELDescriptionNode> getInSC1()
Returns:
the inSC1

getInSC2

public Set<ELDescriptionNode> getInSC2()
Returns:
the inSC2

getOut

public Set<ELDescriptionNode> getOut()
Returns:
the out

getOutSC1

public Set<ELDescriptionNode> getOutSC1()
Returns:
the outSC1

getOutSC2

public Set<ELDescriptionNode> getOutSC2()
Returns:
the outSC2

getTree

public ELDescriptionTree getTree()


SourceForge.net Logo DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2011 Jens Lehmann