Class MartinShortestPath<V,E>
java.lang.Object
org.jgrapht.alg.shortestpath.BaseMultiObjectiveShortestPathAlgorithm<V,E>
org.jgrapht.alg.shortestpath.MartinShortestPath<V,E>
- Type Parameters:
V- the vertex typeE- the edge type
- All Implemented Interfaces:
MultiObjectiveShortestPathAlgorithm<V,E>
Martin's algorithm for the multi-objective shortest paths problem.
Martin's label setting algorithm is a multiple objective extension of Dijkstra's algorithm, where the minimum operator is replaced by a dominance test. It computes a maximal complete set of efficient paths when all the cost values are non-negative.
Note that the multi-objective shortest path problem is a well-known NP-hard problem.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classA node label.private classLexicographic comparator of two node labels.Nested classes/interfaces inherited from interface MultiObjectiveShortestPathAlgorithm
MultiObjectiveShortestPathAlgorithm.MultiObjectiveSingleSourcePaths<V,E> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.jheaps.Heap<MartinShortestPath<V, E>.Label> private final Map<V, LinkedList<MartinShortestPath<V, E>.Label>> private final intFields inherited from class BaseMultiObjectiveShortestPathAlgorithm
graph, GRAPH_MUST_CONTAIN_THE_SINK_VERTEX, GRAPH_MUST_CONTAIN_THE_SOURCE_VERTEX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildPaths(V source) Build the actual paths from the final labels of each node.private static booleandominates(double[] a, double[] b) Return whether a vector dominates another.Compute all shortest paths starting from a single source vertex.Get a shortest path from a source vertex to a sink vertex.private voidrunAlgorithm(V source) Execute the main algorithmprivate static double[]sum(double[] a, double[] b) Compute the sum of two vectorsprivate intvalidateEdgeWeightFunction(Function<E, double[]> edgeWeightFunction) Check the validity of the edge weight functionMethods inherited from class BaseMultiObjectiveShortestPathAlgorithm
createEmptyPath
-
Field Details
-
edgeWeightFunction
-
objectives
private final int objectives -
nodeLabels
-
heap
-
-
Constructor Details
-
MartinShortestPath
-
-
Method Details
-
getPaths
-
getPaths
Description copied from interface:MultiObjectiveShortestPathAlgorithmCompute all shortest paths starting from a single source vertex.- Specified by:
getPathsin interfaceMultiObjectiveShortestPathAlgorithm<V,E> - Overrides:
getPathsin classBaseMultiObjectiveShortestPathAlgorithm<V,E> - Parameters:
source- the source vertex- Returns:
- the shortest paths
-
runAlgorithm
Execute the main algorithm -
buildPaths
-
sum
private static double[] sum(double[] a, double[] b) Compute the sum of two vectors- Parameters:
a- the first vectorb- the second vector- Returns:
- the sum
-
dominates
private static boolean dominates(double[] a, double[] b) Return whether a vector dominates another.- Parameters:
a- the first vectorb- the second vector- Returns:
- true if the first vector dominates the second
-
validateEdgeWeightFunction
-