Package org.graphstream.algorithm
Class LongestPath
java.lang.Object
org.graphstream.algorithm.LongestPath
- All Implemented Interfaces:
Algorithm
public class LongestPath extends Object implements Algorithm
Implementation of longest path algorithm in a DAG (directed acyclic graph) using topologicalSort
- Computational Complexity :
- yet to be calculated
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_WEIGHT_ATTRIBUTEDefault weight attribute -
Constructor Summary
Constructors Constructor Description LongestPath() -
Method Summary
Modifier and Type Method Description voidcompute()Run the algorithm.StringdefaultResult()org.graphstream.graph.PathgetLongestPath()gets longest pathList<org.graphstream.graph.Node>getLongestPathList()gets sorted list of the longest pathDoublegetLongestPathValue()get value of longest path if unweighted value = hopsStringgetWeightAttribute()voidinit(org.graphstream.graph.Graph theGraph)Initialization of the algorithm.voidsetWeightAttribute(String weightAttribute)
-
Field Details
-
DEFAULT_WEIGHT_ATTRIBUTE
Default weight attribute- See Also:
- Constant Field Values
-
-
Constructor Details
-
LongestPath
public LongestPath()
-
-
Method Details
-
init
public void init(org.graphstream.graph.Graph theGraph)Description copied from interface:AlgorithmInitialization of the algorithm. This method has to be called before theAlgorithm.compute()method to initialize or reset the algorithm according to the new given graph. -
compute
public void compute()Description copied from interface:AlgorithmRun the algorithm. TheAlgorithm.init(Graph)method has to be called before computing.- Specified by:
computein interfaceAlgorithm- See Also:
Algorithm.init(Graph)
-
getLongestPathList
gets sorted list of the longest path- Returns:
- sorted list of nodes in longest path
-
getLongestPath
public org.graphstream.graph.Path getLongestPath()gets longest path- Returns:
- longest path
-
defaultResult
-
getLongestPathValue
get value of longest path if unweighted value = hops- Returns:
- value of longest path
-
getWeightAttribute
-
setWeightAttribute
-