1 / 12

GRAPHS

GRAPHS. ÖZET. Graph Representations. Adjacency List. Adjacency Matrix. Other Representations? Combinations of Data Structures. Çizgelerin Dolaşılması Graph Traversal. Derinlik Öncelikli Dolaşma Depth-First Traversal Genişlik Öncelikli Dolaşma Breadth-First Traversal.

Download Presentation

GRAPHS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GRAPHS ÖZET

  2. Graph Representations AdjacencyList AdjacencyMatrix Other Representations? Combinations of Data Structures

  3. Çizgelerin DolaşılmasıGraph Traversal • Derinlik Öncelikli Dolaşma Depth-First Traversal • Genişlik Öncelikli DolaşmaBreadth-First Traversal

  4. Depth-First Traversal The pseudocode of depth-first traversal algorithm: Boolean visited[MAXVERTEX]; void DepthFirst(Graph G) { Vertex v; for (all v in G) visited[v] = FALSE; for (all v in G) if (!visited[v]) Traverse(v); }

  5. Depth-First Traversal void Traverse(Vertex v){ visited[v] = TRUE; Visit(v); for (all w adjacent to v) if (!visited[w]) Traverse(w); } Zaman Karmaşıklığı : O(n+e) veya O(V+E) n, köşe sayısı e, kenar sayısı olmak üzere

  6. Breadth-First Traversal The pseudocode of breadth-first traversal algorithm: BFS(G,s) for each vertex u in V visited[u] = false Report(s) visited[s] = true initialize an empty Q Enqueue(Q,s)

  7. Breadth-First Traversal While Q is not empty do u = Dequeue(Q) for each v in Adj[u] do if visited[v] = false then Report(v) visited[v] = true Enqueue(Q,v) Zaman Karmaşıklığı : O(n+e) veya O(V+E) n, köşe sayısı e, kenar sayısı olmak üzere

  8. En Küçük Kapsayan AğaçMST (Minimum Spanning Tree) Prim’s Algorithm Kruskal’s Algorithm …

  9. Algoritmanın karmaşıklığını, uygulanan sıralama algoritmasının karmaşıklığı belirler: O(|E| lg |E|)

  10. Prim ve Kruskal Algoritmalarının daha etkin olanlarını araştırınız!

  11. Floyd-Warshall: Pseudocode An algorithm to solve the all pairs shortest path problem in a weighted, directed graph for i := 1 to n do for j := 1 to n do cost[i, j] := c[i, j]; // Let c[u, u] := 0 for k := 1 to n do for i := 1 to n do for j := 1 to n do sum = cost[i, k] + cost[k, j]; if(sum < cost[i, j]) then cost[i, j] := sum;

More Related