From ba2f4fdf3d91187b54e93841842d377789c356ea Mon Sep 17 00:00:00 2001 From: Yohan Simard Date: Fri, 15 May 2020 17:01:05 +0200 Subject: [PATCH] A* working and tested --- .../shortestpath/AStarAlgorithm.java | 49 ++++++++++ .../shortestpath/DijkstraAlgorithm.java | 37 ++++--- .../graphs/algorithm/shortestpath/Label.java | 27 ++--- .../algorithm/shortestpath/LabelStar.java | 28 ++++++ .../shortestpath/AStarAlgorithmTest.java | 11 +++ .../shortestpath/DijkstraAlgorithmTest.java | 89 +---------------- .../shortestpath/ShortestPathTest.java | 98 +++++++++++++++++++ .../main/java/org/insa/graphs/model/Path.java | 2 +- 8 files changed, 226 insertions(+), 115 deletions(-) create mode 100644 be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java create mode 100644 be-graphes-algos/src/test/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithmTest.java create mode 100644 be-graphes-algos/src/test/java/org/insa/graphs/algorithm/shortestpath/ShortestPathTest.java diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java index fd172f0..27c8612 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java @@ -1,9 +1,58 @@ package org.insa.graphs.algorithm.shortestpath; +import org.insa.graphs.algorithm.AbstractInputData; +import org.insa.graphs.model.*; + +import java.util.ArrayList; +import java.util.List; + +import static org.insa.graphs.model.GraphStatistics.NO_MAXIMUM_SPEED; + public class AStarAlgorithm extends DijkstraAlgorithm { public AStarAlgorithm(ShortestPathData data) { super(data); } + + /** + * Generates a list of labelStar associated with a graph + * + * @param data the data to use to construct the labels + * @return A list of labels in the same order as data.getGraph().getNodes() + */ + @Override + protected List