Professional Documents
Culture Documents
Department Of CSE
Green University Of Bangladesh
Presentation Topic:
2
CONTENT:
Introduction
BFS Algorithm
Example of BFS algorithm
Bellman Ford Algorithm
Concluding remark
3
Introduction:
4
BFS DFS (UVA 336)
5
Algorithm:
I read the number of edges while edges != 0.
Read the graph.
Read the node to search and the ttl while node !=0
and ttl != 0.
Call bfs(node) and init notReach = 0.
Traverse all the calculated distance from node. If
(distance > ttl) notReach+1;
Traverse the visited map. If an node is not visited.
notReach+1.
Print notReach.
6
Hint of Solution:
The nodes doesnot follow a correlative order.
Carefull with the nodes that are not connected in the
bfs request.(check my case)
7
Source Code:
8
9
10
Bellman Ford Algorithm:
11
Bellman Ford Algorithm Graph:
12
Bellman Ford Algorithm :
Start by considering that the shortest path to all nodes, less the source, is infinity.
Mark the length of the path to the source as 0
Relaxing an edge means checking to see if the path to the node the edge is
pointing to can’t be shortened, and if so, doing it. In the above graph, by checking
the edge 1 -> 2 of length 6, you find that the length of the shortest path to node
1 plus the length of the edge 1 -> 2 is less then infinity. So, you replace infinity
in node 2 with 6.
13
Tricky Lines :
14
Source Code:
15
16
17
Concluding remark:
The basic idea of implementing curiosity and boredom is not limited to the
particular algorithm described in the first section. Every model-dependent on-
line algorithm for learning goal directed behavior might be augmented by a
similar implementation of `the desire to improve the world model'.
18