Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

No Downloads

Total views

413

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

17

Comments

0

Likes

1

No embeds

No notes for slide

- 1. 1 GRAPH
- 2. INTRODUCTION Introduced in 1736 Leonhard Euler Solved “Konigsberg Bridge Problem” 2 Eulerian Circuit or Euler Tour
- 3. KONIGSBERG BRIDGE PROBLEM 3 The problem was to find a walk through the city that would cross each bridge once and only once. The islands could not be reached by any route other than the bridges, and every bridge must have been crossed completely every time; one could not walk halfway onto the bridge and then turn around and later cross the other half from the other side. The walk need to start and end at the same spot.
- 4. 4 KONIGSBERG BRIDGE PROBLEM
- 5. 5 DESIGN OF SOLUTION
- 6. 6 CLASS TASK
- 7. 7 SOLUTION
- 8. CONCLUSION 8 Eularian circuit exists if, and only if, the graph is connected, and there are no nodes of odd degree at all.
- 9. BASIC TERMINOLOGY Graph : Two sets V(G) & E(G) Undirected Graph (u,v) Directed Graph <u,v> Self Edges Multigraph No. of edges = n(n-1)/2(undirected) 9 No. of edges = n(n-1) (directed)
- 10. BASIC TERMINOLOGY Adjacent Vertices Subgraph Path Length of Path Simple Path : all vertices are distinct except first & last 10 Cycle
- 11. BASIC TERMINOLOGY Connected Vertices Connected graph Connected Components : maximal connected subgraph Acyclic Graph Strongly Connected 11 Strongly Connected Components
- 12. BASIC TERMINOLOGY Degree In-degree Out-degree 12 Weighted Edges
- 13. GRAPH REPRESENTATION Adjacency Matrix 13 Adjacency List
- 14. OPERATIONS ON GRAPH Depth-First Search Breadth-First Search Connected Components 14 Shortest Path Algorithm
- 15. DEPTH-FIRST SEARCH Void Graph ::DFS( ) Visited = new boolean[n]; For(int I=0;I<n;I++) visited [I] = false; DFS(0); Delete [] visited; Void Graph ::DFS(const int v) visited [v] = true; for( each vertex w adjacent to v) if(! Visited [w]) DFS(w); 15 • • • •
- 16. BREADTH-FIRST SEARCH Void Graph ::BFS(int v) • Visited = new boolean[n]; • For(int I=0; I<n; I++) visited [I] = false; • Visited [v] = true; • Queue<int> q; • Q.insert(v); • While(!q.IsEmpty()) • V= *q.delete(v); • For(all vertices w adjacent to v) • If(!visited [w]) • q.Insert(w); • Visited [w] = true; 16 • Delete [] visited;
- 17. CONNECTED COMPONENT Void Graph::Components( ) • Visited = new boolean [n]; • For(int I = 0;I < n; I++) visited [I] = false; • For(I=0; I < n; I++) • If (! Visited [I]) • DFS (I); • OutputNewComponent(); 17 • Delete [ ] visited;
- 18. SHORTEST PATH Void Graph::ShortestPath(int n, int v) • For(int I=0; I<n; I++) {s[I] =false;dist[I]=length[v][I];} • S[v] = true; • Dist[v] = 0; • For(I=0; I<=n-2; I++) 18 • Int u=choose(n); • S[u] = true; • For(int w=0; w<n; w++) • If(!s[w]) • If(dist[u] + length[u][w] < dist[w]) • Dist[w] = dist[u] + length[u][w];
- 19. EXAMPLE 1 2 3 4 0 0 5 10 ∞ ∞ 1 ∞ 0 3 2 9 2 ∞ ∞ 0 6 ∞ 3 ∞ ∞ ∞ 0 4 4 ∞ ∞ ∞ ∞ 0 19 0

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment