Class GraphAnalyzer

  • Direct Known Subclasses:
    GraphMatcher

    public abstract class GraphAnalyzer
    extends java.lang.Object
    Superclass of classes that need to analyze the graph structures of models.
    Since:
    Ptolemy II 7.1
    Version:
    $Id$
    Author:
    Thomas Huining Feng
    Pt.AcceptedRating:
    Red (tfeng)
    Pt.ProposedRating:
    Yellow (tfeng)
    • Constructor Detail

      • GraphAnalyzer

        public GraphAnalyzer()
    • Method Detail

      • findFirstChild

        public NamedObj findFirstChild​(CompositeEntity top,
                                       GraphAnalyzer.IndexedLists indexedLists,
                                       java.util.Collection<java.lang.Object> excludedObjects)
        Find the first child within the top composite entity. The child is either an atomic actor (AtomicActor) or an opaque composite entity, one that has a director in it. If the top composite entity does not have any child, null is returned.
        Parameters:
        top - The top composite entity in which the search is performed.
        indexedLists - A list that is used to encode the composite entities visited.
        excludedObjects - The atomic actor or opaque composite entities that should not be returned.
        Returns:
        The child found, or null if none.
        See Also:
        findNextChild(CompositeEntity, IndexedLists, Collection)
      • findFirstPath

        public boolean findFirstPath​(Port startPort,
                                     GraphAnalyzer.Path path,
                                     java.util.Set<? super Relation> visitedRelations,
                                     java.util.Set<? super Port> visitedPorts)
        Find the first path starting from the startPort, and store it in the path parameter if found. A path is a sequence of alternating ports (Port) and relations (Relation), starting and ending with two ports (which may be equal, in which case the path is a loop). If a path contains ports between the start port and the end port, those ports in between must be ports of a transparent composite entities (those with no directors inside). If no path is found starting from the startPort, null is returned.
        Parameters:
        startPort - The port from which the search starts.
        path - The path to obtain the result.
        visitedRelations - A set that records all the relations that have been visited during the search.
        visitedPorts - A set that records all the ports that have been visited during the search.
        Returns:
        true if a path is found and stored in the path parameter; false otherwise.
        See Also:
        findNextPath(Path, Set, Set)
      • findNextChild

        public NamedObj findNextChild​(CompositeEntity top,
                                      GraphAnalyzer.IndexedLists indexedLists,
                                      java.util.Collection<java.lang.Object> excludedObjects)
        Find the next child within the top composite entity. The child is either an atomic actor (AtomicActor) or an opaque composite entity, one that has a director in it. If the top composite entity does not have any more child, null is returned.
        Parameters:
        top - The top composite entity in which the search is performed.
        indexedLists - A list that is used to encode the composite entities visited.
        excludedObjects - The atomic actor or opaque composite entities that should not be returned.
        Returns:
        The child found, or null if none.
        See Also:
        findFirstChild(CompositeEntity, IndexedLists, Collection)
      • findNextPath

        public boolean findNextPath​(GraphAnalyzer.Path path,
                                    java.util.Set<Relation> visitedRelations,
                                    java.util.Set<Port> visitedPorts)
        Find the next path, and store it in the path parameter if found. A path is a sequence of alternating ports (Port) and relations (Relation), starting and ending with two ports (which may be equal, in which case the path is a loop). If a path contains ports between the start port and the end port, those ports in between must be ports of a transparent composite entities (those with no directors inside). If no more path is found, null is returned.
        Parameters:
        path - The path to obtain the result.
        visitedRelations - A set that records all the relations that have been visited during the search.
        visitedPorts - A set that records all the ports that have been visited during the search.
        Returns:
        true if a path is found and stored in the path parameter; false otherwise.
        See Also:
        findFirstPath(Port, Path, Set, Set)
      • _isIgnored

        protected boolean _isIgnored​(java.lang.Object object)
        Test whether an object should be ignored from analysis.
        Parameters:
        object - The object to be tested.
        Returns:
        true if the object should be ignored; false otherwise.
      • _isOpaque

        protected abstract boolean _isOpaque​(CompositeEntity entity)
        Test whether a composite entity should be considered as opaque.
        Parameters:
        entity - The composite entity to be tested.
        Returns:
        true if the composite object should be considered as opaque; false otherwise.
      • _relationCollapsing

        protected abstract boolean _relationCollapsing​(NamedObj container)
        Test whether the relations contained in the container should be considered as collapsed, i.e., whether multiple connected relations should be considered as just one.
        Parameters:
        container - The container.
        Returns:
        true if the relations should be considered as collapsed; false otherwise.