Chapter 16 1 – Graphs Graph Categories Strong Components

Slides:



Advertisements
Similar presentations
What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Advertisements

CSE Lectures 18 – Graphs Graphs & Characteristics
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Topological Sort Topological sort is the list of vertices in the reverse order of their finishing times (post-order) of the depth-first search. Topological.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
1 Dijkstra’s Minimum-Path Algorithm Minimum Spanning Tree CSE Lectures 20 – Intro to Graphs.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Data Structures Using C++
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Graph & BFS.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CS344: Lecture 16 S. Muthu Muthukrishnan. Graph Navigation BFS: DFS: DFS numbering by start time or finish time. –tree, back, forward and cross edges.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
1 Graphs & Characteristics Graph Representations A Representation in C++ (Ford & Topp) Searching (DFS & BFS) Connected Components Graph G and Its Transpose.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
– Graphs 1 Graph Categories Strong Components Example of Digraph
Graphs Upon completion you will be able to:
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Main Index Contents 11 Main Index Contents Graph Categories Graph Categories Example of Digraph Example of Digraph Connectedness of Digraph Connectedness.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
Graph Search Applications, Minimum Spanning Tree
Introduction to Algorithms
Graphs A New Data Structure
Graphs Chapter 20.
Minimum Spanning Trees
Chapter 22 Elementary Graph Algorithms
Graphs Representation, BFS, DFS
Undirected versus Directed Graphs
Data Structures 13th Week
CSE 2331/5331 Topic 9: Basic Graph Alg.
Graph Search Lecture 17 CS 2110 Fall 2017.
Lecture 12 Graph Algorithms
Chapter 14 Graph Algorithms
Introduction to Graphs
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
CS202 - Fundamental Structures of Computer Science II
CS120 Graphs.
Short paths and spanning trees
Graph Algorithm.
Graphs Graph transversals.
Graph Representation Adjacency list representation of G = (V, E)
Lecture 10 Algorithm Analysis
Graph & BFS.
Graphs Representation, BFS, DFS
Minimum Spanning Trees
Graph Algorithm.
Graphs Chapter 13.
Search Related Algorithms
Graph Representation (23.1/22.1)
Chapter 11 Graphs.
Richard Anderson Autumn 2016 Lecture 5
ITEC 2620M Introduction to Data Structures
CSCI2100 Data Structures Tutorial
Graph Implementation.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Graph Algorithm.
GRAPH – Definitions A graph G = (V, E) consists of
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Chapter 16 1 – Graphs Graph Categories Strong Components Main Index Contents Chapter 16 – Graphs Graph Categories Example of Digraph Connectedness of Digraph Adjacency Matrix Adjacency Set vertexInfo Object Vertex Map and Vector vInfo VtxMap and Vinfo Example Breadth-First Search Algorithm (2 slides) Dfs() Strong Components Graph G and Its Transpose GT Shortest-Path Example (2 slides) Dijkstra Minimum-Path Algorithm (2 slides) Minimum Spanning Tree Example Minimum Spanning Tree: vertices A and B Completing the Minimum Spanning-Tree with Vertices C and D Summary Slides (4 slides)

A graph is connected if each pair of vertices have a path between them 2 Main Index Contents Graph Categories A graph is connected if each pair of vertices have a path between them A complete graph is a connected graph in which each pair of vertices are linked by an edge

Graph with ordered edges are called directed graphs or digraphs 3 Main Index Contents Example of Digraph Graph with ordered edges are called directed graphs or digraphs

Connectedness of Digraph 4 Main Index Contents Connectedness of Digraph Strongly connected if there is a path from any vertex to any other vertex. Weakly connected if, for each pair of vertices vi and vj, there is either a path P(vi, vj) or a path P(vi,vj).

5 Main Index Contents Adjacency Matrix An m by m matrix, called an adjacency matrix, identifies the edges. An entry in row i and column j corresponds to the edge e = (v,, vj). Its value is the weight of the edge, or -1 if the edge does not exist.

6 Main Index Contents Adjacency Set

7 Main Index Contents vertexInfo Object A vertexInfo object consists of seven data members. The first two members, called vtxMapLoc and edges, identify the vertex in the map and its adjacency set.

Vertex Map and Vector vInfo 8 Main Index Contents Vertex Map and Vector vInfo To store the vertices in a graph, we provide a map<T,int> container, called vtxMap, where a vertex name is the key of type T. The int field of a map object is an index into a vector of vertexInfo objects, called vInfo. The size of the vector is initially the number of vertices in the graph, and there is a 1-1 correspondence between an entry in the map and a vertexInfo entry in the vector

VtxMap and Vinfo Example

Breadth-First Search Algorithm

Breadth-First Search… (Cont.)

dfs()

Strong Components A strongly connected component of a graph G is a maximal set of vertices SC in G that are mutually accessible.

Graph G and Its Transpose GT The transpose has the same set of vertices V as graph G but a new edge set ET consisting of the edges of G but with the opposite direction.

Shortest-Path Example The shortest-path algorithm includes a queue that indirectly stores the vertices, using the corresponding vInfo index. Each iterative step removes a vertex from the queue and searches its adjacency set to locate all of the unvisited neighbors and add them to the queue.

Shortest-Path Example 16 Main Index Contents Shortest-Path Example Example: Find the shortest path for the previous graph from F to C.

Dijkstra Minimum-Path Algorithm From A to D Example 17 Main Index Contents Dijkstra Minimum-Path Algorithm From A to D Example

Dijkstra Minimum-Path Algorithm From… (Cont…)

Minimum Spanning Tree Example 19 Main Index Contents Minimum Spanning Tree Example

Minimum Spanning Tree: Vertices A and B 20 Main Index Contents Minimum Spanning Tree: Vertices A and B

Completing the Minimum Spanning-Tree Algorithm with Vertices C and D

§- Undirected and Directed Graph (digraph) 22 Main Index Contents Summary Slide 1 §- Undirected and Directed Graph (digraph) - Both types of graphs can be either weighted or nonweighted.

§- Breadth-First, bfs() 23 Main Index Contents Summary Slide 2 §- Breadth-First, bfs() - locates all vertices reachable from a starting vertex - can be used to find the minimum distance from a starting vertex to an ending vertex in a graph.

§- Depth-First search, dfs() 24 Main Index Contents Summary Slide 3 §- Depth-First search, dfs() - produces a list of all graph vertices in the reverse order of their finishing times. - supported by a recursive depth-first visit function, dfsVisit() - an algorithm can check to see whether a graph is acyclic (has no cycles) and can perform a topological sort of a directed acyclic graph (DAG) - forms the basis for an efficient algorithm that finds the strong components of a graph

§- Dijkstra's algorithm 25 Main Index Contents Summary Slide 4 §- Dijkstra's algorithm - if weights, uses a priority queue to determine a path from a starting to an ending vertex, of minimum weight - This idea can be extended to Prim's algorithm, which computes the minimum spanning tree in an undirected, connected graph.