8 Uniform Cost Search 02-08-2024
8 Uniform Cost Search 02-08-2024
BCSE306
Artificial Intelligence
Dr.Priyanka N
Assistant Professor
VIT Vellore,
UNIFORM COST SEARCH
• Uniform Cost Search is an algorithm used to move around a
directed weighted search space to go from a start node to
one of the ending nodes with a minimum cumulative cost.
• This search is an uninformed search algorithm since it
operates in a brute-force manner, i.e. it does not take the
state of the node or search space into consideration.
• It is used to find the path with the lowest cumulative cost in a
weighted graph where nodes are expanded according to their
cost of traversal from the root node.
• This is implemented using a priority queue where lower the
cost higher is its priority.
Algorithm
• Insert RootNode into the queue.
• Repeat till queue is not empty:
– Remove the next element with the highest priority from the
queue.
– If the node is a destination node, then print the cost and the
path and exit
– else insert all the children of removed elements into the
queue with their cumulative cost as their priorities.
NOTE: Here rootNode is the starting node for the path, and a
priority queue is being maintained to maintain the path with
the least cost to be chosen for the next traversal. In case 2
paths have the same cost of traversal, nodes are considered
alphabetically.
3
4
Queue A B C
Cost 1 3 5
Queue B C G
Cost 3 5 4
5
Queue C G F
Cost 5 4 8
Queue C F
Cost 5 8
6
Queue F E
Cost 8 7
7
Visited Nodes: A,B,G,C,E
Queue F Dest
Cost 8 8
8
Advantages
•It helps to find the path with the lowest cumulative cost inside a
weighted graph having a different cost associated with each of
its edges from the root node to the destination node.
•It is considered an optimal solution since, at each state, the
least path is considered to be followed.
Disadvantage
•The open list must be kept sorted as priorities in the priority
queue need to be maintained.
•The storage required is exponentially large.
•The algorithm may be stuck in an infinite loop as it considers
every possible path from the root node to the destination node.