Class AllEdgeSingleSourceLongestPathStrategy

    • Constructor Detail

      • AllEdgeSingleSourceLongestPathStrategy

        public AllEdgeSingleSourceLongestPathStrategy​(Graph graph,
                                                      Node startNode,
                                                      ToDoubleMapping edgeLengths)
        Construct an instance of this analyzer.
        Parameters:
        graph - The given graph.
        startNode - The node from which the longest path is going to be calculated.
        edgeLengths - The lengths of the edges of the given graph, which are going to be used to calculated the longest path.
    • Method Detail

      • distance

        public double[] distance()
        Return the distance from the start node to all the other nodes in the graph. The result is a double[] indexed by the destination node label.
        Specified by:
        distance in interface SingleSourceLongestPathAnalyzer
        Returns:
        Return the distance from the start node to all the other nodes in the graph.
        See Also:
        Graph.nodeLabel(ptolemy.graph.Node)
      • path

        public java.util.List path​(Node endNode)
        Return the longest path from node startNode to node endNode in the form of an ordered list. The source node is defined in the constructor, and can be changed using setStartNode(ptolemy.graph.Node). The result includes the starting and the ending nodes.
        Specified by:
        path in interface SingleSourceLongestPathAnalyzer
        Parameters:
        endNode - The ending node of the path.
        Returns:
        The longest path.
      • pathLength

        public double pathLength​(Node endNode)
        Return the length of the longest path from node startNode to node endNode. The source node is defined in the constructor and can be changed using setStartNode(ptolemy.graph.Node).
        Specified by:
        pathLength in interface SingleSourceLongestPathAnalyzer
        Parameters:
        endNode - The ending node of the path.
        Returns:
        The length of the longest path.
      • toString

        public java.lang.String toString()
        Return a description of the analyzer.
        Specified by:
        toString in interface Analyzer
        Overrides:
        toString in class CachedStrategy
        Returns:
        Return a description of the analyzer..
      • valid

        public boolean valid()
        Check for compatibility between the analysis and the given graph. A graph needs to be an instance of a DirectedGraph and acyclic in order to use this algorithm. This compatibility check runs in O(N^3) in which N is the number of nodes.
        Specified by:
        valid in interface Analyzer
        Returns:
        True if the graph is a directed graph and acyclic.
      • _compute

        protected java.lang.Object _compute()
        The computation associated with this analyzer.
        Overrides:
        _compute in class CachedStrategy
        Returns:
        The result of the computation.