# What is the best alternative to Breadth-first search?

Here’s the Deal

Slant is powered by a community that helps you make informed decisions. Tell us what you’re passionate about to get your personalized feed and help others.

### Pro Heuristic

A* expands on a node only if it seems promising. It's only focus is to reach the goal node as quickly as possible from the current node, not to try and reach every other node.

### Pro Complete

A* is complete, which means that it will always find a solution if it exists.

### Pro Can be morphed into other algorithms

A* can be morphed into another path-finding algorithm by simply playing with the heuristics it uses and how it evaluates each node. This can be done to simulate Dijkstra, Best First Search, Breadth First Search and Depth First Search.

### Con Not useful if you have many target nodes

If you have many target nodes and you don't know which one is closest to the main one, A* is not very optimal. This is because it needs to be run several times (once per target node) in order to get to all of them.

### Pro Uninformed algorithm

Dijkstra is an uninformed algorithm. This means that it does not need to know the target node beforehand. For this reason it's optimal in cases where you don't have any prior knowledge of the graph when you cannot estimate the distance between each node and the target.

### Pro Good when you have multiple target nodes

Since Dijkstra picks edges with the smallest cost at each step it usually covers a large area of the graph. This is especially useful when you have multiple target nodes but you don't know which one is the closest.

### Con Fails for negative edge weights

If we take for example 3 Nodes (A, B and C) where they form an undirected graph with edges: AB = 3, AC = 4, BC=-2, the optimal path from A to C costs 1 and the optimal path from A to B costs 2. If we apply Dijkstra's algorithm: starting from A it will first examine B because it is the closest n...

Help millions of people make better decisions.

Each month, over 1.7 million people use Slant to find the best products and share their knowledge. Pick the tags you’re passionate about to get a personalized feed and begin contributing your knowledge.