Description Usage Arguments Details Value See Also Examples
Use the A*-Search algorithm to solve a shortest path problem.
1 | aStarSearch(graph, from, to, distance.heuristic = euclidean.vertex.distance)
|
graph |
The graph object. |
from |
The source vertex |
to |
The target vertex |
distance.heuristic |
The A* distance heuristic. |
A*-Search is a single-source algorithm which cannot deal with negative edge weights.
Compared to Dijkstra's algorithm (dijkstra
), it uses an euclidean distance heuristic to estimate
the minimum distance to the target vertex and thereby rule out solutions.
Thus, it is usually vastly faster than Dijkstra, but requires an euclidean problem instance.
An spresults
object.
setRandomVertexCoordinates
and setVertexCoordinatesFromLayout
to set vertex coordinates for a graph object.
euclidean.vertex.distance
for the default distance heuristic.
1 2 3 4 5 6 7 8 | g <- randomGraph(6, euclidean=TRUE)
d <- aStarSearch(g, "A", "F")
plot(d)
for(step in d){
print(step$min_dists)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.