Class DAGConceptGraph

  • All Implemented Interfaces:
    CPO<Concept>

    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)
    • Constructor Detail

      • DAGConceptGraph

        public DAGConceptGraph()
        Create an empty concept graph with no concepts in it.
    • 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 concept
        concept2 - The sink concept
        conceptRelation - 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 interface CPO<Concept>
        Specified by:
        bottom in class ConceptGraph
        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 of Concept, 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 interface CPO<Concept>
        Specified by:
        compare in class ConceptGraph
        Parameters:
        e1 - An instance of Concept.
        e2 - An instance of Concept.
        Returns:
        One of CPO.LOWER, CPO.SAME, CPO.HIGHER, CPO.INCOMPARABLE.
        Throws:
        java.lang.IllegalArgumentException - If one or both arguments are not instances of Concept.
      • 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 interface CPO<Concept>
        Overrides:
        downSet in class ConceptGraph
        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 interface CPO<Concept>
        Overrides:
        greatestLowerBound in class ConceptGraph
        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 class ConceptGraph
        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 interface CPO<Concept>
        Specified by:
        leastUpperBound in class ConceptGraph
        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 interface CPO<Concept>
        Specified by:
        top in class ConceptGraph
        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 interface CPO<Concept>
        Overrides:
        upSet in class ConceptGraph
        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.