Package ptolemy.data.ontologies
Class DAGConceptGraph
- java.lang.Object
-
- ptolemy.data.ontologies.ConceptGraph
-
- ptolemy.data.ontologies.DAGConceptGraph
-
public class DAGConceptGraph extends ConceptGraph
A data structure representing relationships of ontologies whose structure can be represented as a directed acyclic graph of concepts. This corresponds directly to the subset of ontologies that users can construct in the Ontology Editor.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Thomas Mandl, Man-Kit Leung, Edward A. Lee, Ben Lickly, Dai Bui, Christopher Brooks
- See Also:
ConceptGraph
- Pt.AcceptedRating:
- Red (mankit)
- Pt.ProposedRating:
- Red (mankit)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ptolemy.graph.CPO
CPO.BoundType
-
-
Field Summary
-
Fields inherited from interface ptolemy.graph.CPO
HIGHER, INCOMPARABLE, LOWER, SAME
-
-
Constructor Summary
Constructors Constructor Description DAGConceptGraph()
Create an empty concept graph with no concepts in it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConcept(FiniteConcept concept)
Add a concept to this concept graph.void
addRelation(FiniteConcept concept1, FiniteConcept concept2, ConceptRelation conceptRelation)
Add a relation between two Concepts as an edge to the graph.Concept
bottom()
Return the least element of this concept graph.java.util.List<Concept>
checkUnacceptableConcepts()
Return a list of the concepts which are not acceptable, but are also not at the top of the lattice, as required for non-acceptable concepts.int
compare(java.lang.Object e1, java.lang.Object e2)
Compare two concepts in the ontology.Concept[]
downSet(java.lang.Object e)
Compute the down-set of an element in this concept graph.Concept
greatestLowerBound(java.lang.Object e1, java.lang.Object e2)
Compute the greatest lower bound (GLB) of two elements.Concept
leastUpperBound(java.lang.Object e1, java.lang.Object e2)
Compute the least upper bound (LUB) of two elements.NonLatticeCounterExample
nonLatticeReason()
Return why this concept graph is not a lattice, or null if it is.Concept
top()
Return the greatest element in this concept graph.Concept[]
upSet(java.lang.Object e)
Compute the up-set of an element in this concept graph.-
Methods inherited from class ptolemy.data.ontologies.ConceptGraph
greatestElement, greatestLowerBound, isLattice, leastElement, leastUpperBound
-
-
-
-
Method Detail
-
addConcept
public void addConcept(FiniteConcept concept)
Add a concept to this concept graph.- Parameters:
concept
- The concept.- Throws:
java.lang.IllegalArgumentException
- If the concept we are trying to add is already contained in this concept graph.
-
addRelation
public void addRelation(FiniteConcept concept1, FiniteConcept concept2, ConceptRelation conceptRelation)
Add a relation between two Concepts as an edge to the graph.- Parameters:
concept1
- The source conceptconcept2
- The sink conceptconceptRelation
- The ConceptRelation between the two concepts concept1 and concept2.
-
bottom
public Concept bottom()
Return the least element of this concept graph.- Specified by:
bottom
in interfaceCPO<Concept>
- Specified by:
bottom
in classConceptGraph
- Returns:
- The least element of this graph.
-
checkUnacceptableConcepts
public java.util.List<Concept> checkUnacceptableConcepts()
Return a list of the concepts which are not acceptable, but are also not at the top of the lattice, as required for non-acceptable concepts.- Returns:
- A list of concepts erroneously marked as not acceptable, or an empty list if there are no errors.
-
compare
public int compare(java.lang.Object e1, java.lang.Object e2)
Compare two concepts in the ontology. The arguments must be instances ofConcept
, otherwise an exception will be thrown. This method returns one of ptolemy.graph.CPO.LOWER, ptolemy.graph.CPO.SAME, ptolemy.graph.CPO.HIGHER, ptolemy.graph.CPO.INCOMPARABLE, indicating the first argument is lower than, equal to, higher than, or incomparable with the second argument in the property hierarchy, respectively.- Specified by:
compare
in interfaceCPO<Concept>
- Specified by:
compare
in classConceptGraph
- Parameters:
e1
- An instance ofConcept
.e2
- An instance ofConcept
.- Returns:
- One of CPO.LOWER, CPO.SAME, CPO.HIGHER, CPO.INCOMPARABLE.
- Throws:
java.lang.IllegalArgumentException
- If one or both arguments are not instances ofConcept
.
-
downSet
public Concept[] downSet(java.lang.Object e)
Compute the down-set of an element in this concept graph. The down-set of an element is the subset consisting of all the elements less than or equal to the specified element.- Specified by:
downSet
in interfaceCPO<Concept>
- Overrides:
downSet
in classConceptGraph
- Parameters:
e
- An Object representing an element in this concept graph.- Returns:
- An array of Concepts of the down-set of the specified element.
- Throws:
java.lang.IllegalArgumentException
- If the specified Object is not an element in this concept graph, or the resulting set is infinite.
-
greatestLowerBound
public Concept greatestLowerBound(java.lang.Object e1, java.lang.Object e2)
Compute the greatest lower bound (GLB) of two elements. The GLB of two elements is the greatest element in the concept graph that is less than or equal to both of the two elements.- Specified by:
greatestLowerBound
in interfaceCPO<Concept>
- Overrides:
greatestLowerBound
in classConceptGraph
- Parameters:
e1
- An Object representing an element in this concept graph.e2
- An Object representing an element in this concept graph.- Returns:
- A Concept representing the GLB of the two specified
elements, or
null
if the GLB does not exist. - Throws:
java.lang.IllegalArgumentException
- If at least one of the specified Objects is not an element of this concept graph.
-
nonLatticeReason
public NonLatticeCounterExample nonLatticeReason()
Return why this concept graph is not a lattice, or null if it is. Should be null for all existing concept graphs.- Specified by:
nonLatticeReason
in classConceptGraph
- Returns:
- Null, if the concept graph is a lattice.
-
leastUpperBound
public Concept leastUpperBound(java.lang.Object e1, java.lang.Object e2)
Compute the least upper bound (LUB) of two elements. The LUB of two elements is the least element in the concept graph that is greater than or equal to both of the two elements.- Specified by:
leastUpperBound
in interfaceCPO<Concept>
- Specified by:
leastUpperBound
in classConceptGraph
- Parameters:
e1
- An Object representing an element in this concept graph.e2
- An Object representing an element in this concept graph.- Returns:
- A Concept representing the LUB of the two specified
elements, or
null
if the LUB does not exist. - Throws:
java.lang.IllegalArgumentException
- If at least one of the specified Objects is not an element of this concept graph.
-
top
public Concept top()
Return the greatest element in this concept graph.- Specified by:
top
in interfaceCPO<Concept>
- Specified by:
top
in classConceptGraph
- Returns:
- The greatest element in this concept graph.
-
upSet
public Concept[] upSet(java.lang.Object e)
Compute the up-set of an element in this concept graph. The up-set of an element is the subset consisting of all the elements greater than or equal to the specified element.- Specified by:
upSet
in interfaceCPO<Concept>
- Overrides:
upSet
in classConceptGraph
- Parameters:
e
- An Object representing an element in this concept graph.- Returns:
- An array of Concepts of the up-set of the specified element.
- Throws:
java.lang.IllegalArgumentException
- Always thrown.
-
-