Green University of Bangladesh Department of Computer Science and Engineering (CSE)
Green University of Bangladesh Department of Computer Science and Engineering (CSE)
LAB REPORT NO 02
Course Title: Artificial intelligence Lab
Course Code: CSE316 Section: D14
Student Details
Name ID
[For Teachers use only: Don’t Write Anything inside this box]
2. PROBLEM ANALYSIS
Depth-first search is an algorithm for traversing or searching tree or graph data structures. The
algorithm starts at the root node and explores as far as possible along each branch before backtracking.
3. IMPLEMENTATION
• Code:
visited.add(v)
print(v)
for i in self.graph[v]:
if i not in visited:
self.Dfs_Function(i, visited)
if __name__ == "__main__":
graph = Graph()
starting_node = int(input("Enter the starting node: "))
print(" ")
number_of_edges = int(input("Enter the number of edges: "))
for i in range(number_of_edges):
print(" ")
print("This is Edge",i+1)
print(" ")
source = int(input("From: "))
connected_node = int(input("To: "))
graph.Add_The_Edge(source, connected_node)
graph.Dfs_Traversal(starting_node)
4. TEST