0% found this document useful (0 votes)
22 views1 page

Procedure UniformCostSearch

This algorithm performs a uniform cost search on a graph to find the lowest cost path from a root node to a goal node. It maintains a priority queue called the frontier containing nodes to explore ordered by cost. It repeatedly removes the lowest cost node from the frontier, explores its neighbors, and adds them to the frontier if they have not already been explored or are found with lower cost in the frontier. It returns the solution path if the goal node is found or failure if the frontier is empty.

Uploaded by

sathiyavijayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Procedure UniformCostSearch

This algorithm performs a uniform cost search on a graph to find the lowest cost path from a root node to a goal node. It maintains a priority queue called the frontier containing nodes to explore ordered by cost. It repeatedly removes the lowest cost node from the frontier, explores its neighbors, and adds them to the frontier if they have not already been explored or are found with lower cost in the frontier. It returns the solution path if the goal node is found or failure if the frontier is empty.

Uploaded by

sathiyavijayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

procedure UniformCostSearch(Graph, root, goal)

node := root, cost = 0


frontier := priority queue containing node only
explored := empty set
do
if frontier is empty
return failure
node := frontier.pop
if node is goal
return solution
explored.add(node)
for each of node's neighbors n
if n is not in explored
if n is not in frontier
frontier.add(n)
else if n is in frontier with higher cost
replace existing node with n

procedure UniformCostSearch(Graph, root, goal)

node := root, cost = 0


frontier := priority queue containing node only
explored := empty set
do

if frontier is empty
return failure

node := frontier.pop
if node is goal
return solution
explored.add(node)
for each of node's neighbors n
if n is not in explored
if n is not in frontier
frontier.add(n)
else if n is in frontier with higher cost
replace existing node with n

You might also like