How to check if search problem has no solution in depth limit search?

Discussion in 'Other Advanced Math' started by shivajikobardan, Feb 2, 2022.

  1. shivajikobardan

    shivajikobardan

    Joined:
    Jan 8, 2022
    Messages:
    41
    Likes Received:
    6
    Depth-limited search can be terminated with two Conditions of failure:


    Standard Failure: it indicates that the problem does not have any solutions.


    Cutoff Failure Value: It defines no solution for the problem within a given depth limit.


    https://www.analyticsvidhya.com/blog/2021/02/uninformed-search-algorithms-in-ai/


    https://www.javatpoint.com/ai-uninformed-search-algorithms


    I checked for cut off failure. But I don't know how to check for standard failure. Can you guide me a bit?



    Code:
    
    # Python dictionary to act as an adjacency list
    
    graph = {
    
      '7' : ['19','21', '14'],
    
      '19': ['1', '12', '31'],
    
      '21': [],
    
      '14': ['23', '6'],
    
      '1' : [],
    
      '12': [],
    
      '31': [],
    
      '23': [],
    
      '6' : []
    
    }
    
    
    goal='6'
    
    visited = [] # List of visited nodes of graph.
    
    def dls(visited, graph, node,depth):
    
       if(depth>=0):
    
           
    
           
    
    
    
           if node not in visited:
    
               visited.append(node)
    
           
    
           if(node==goal):
    
               print("goal found")
    
               print("path to goal=",visited)
    
               exit()
    
    
    
           for neighbor in graph[node]:
    
               dls(visited, graph, neighbor,depth-1)
    
           
    
    
           print(node)
    
    
    # Driver Code
    
    print("Following is the Depth-First Search")
    
    res=dls(visited, graph, '7',1)
    
    if(res):
    
       print("Path to goal node available")
    
       print("Path",path)
    
    else:
    
       print("No path available for the goal node in given depth limit ie cut off failure")
    
    
    print("visited=",visited)
    
    
     
    shivajikobardan, Feb 2, 2022
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...