Lecture 13 Graphs. Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Analysis of Algorithms CS 477/677
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Representing Graphs. 2 Adjacency Matrix Suppose we have a graph G with n nodes. The adjacency matrix is the n x n matrix A=[a ij ] with: a ij = 1 if.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R5. Graphs.
Graphs Intro G.Kamberova, Algorithms Graphs Introduction Gerda Kamberova Department of Computer Science Hofstra University.
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Connected Components, Directed Graphs, Topological Sort COMP171.
Introduction to Graphs
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
CTIS 154 Discrete Mathematics II1 8.2 Paths and Cycles Kadir A. Peker.
Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects two different vertices. Edges are.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Chapter 9: Graphs Basic Concepts
Minimum Spanning Tree Algorithms. What is A Spanning Tree? u v b a c d e f Given a connected, undirected graph G=(V,E), a spanning tree of that graph.
1 Abstract Data Type We have discussed: List Tree Today we will talk about Graph.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
CS 3343: Analysis of Algorithms Lecture 21: Introduction to Graphs.
Computer Science 112 Fundamentals of Programming II Introduction to Graphs.
GRAPH THEORY.  A graph is a collection of vertices and edges.  An edge is a connection between two vertices (or nodes).  One can draw a graph by marking.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
7.1 and 7.2: Spanning Trees. A network is a graph that is connected –The network must be a sub-graph of the original graph (its edges must come from the.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
Lecture 14 Graph Representations. Graph Representation – How do we represent a graph internally? – Two ways adjacency matrix list – Adjacency Matrix For.
Spring 2007Graphs1 ORD DFW SFO LAX
Mathematics of Networks (Cont)
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.
COSC 2007 Data Structures II Chapter 14 Graphs I.
Data Structures CSCI 132, Spring 2014 Lecture 38 Graphs
Depth-First Search Lecture 21: Graph Traversals
1/16/20161 Introduction to Graphs Advanced Programming Concepts/Data Structures Ananda Gunawardena.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Graphs 황승원 Fall 2010 CSE, POSTECH. 2 2 Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 10 Prepared by İnanç TAHRALI.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which.
CSC 213 – Large Scale Programming Lecture 31: Graph Traversals.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Graphs ORD SFO LAX DFW Graphs 1 Graphs Graphs
Graphs.
CS 201: Design and Analysis of Algorithms
Graphs Lecture 19 CS2110 – Spring 2013.
Introduction to Graphs
Introduction to Graphs
CS 3343: Analysis of Algorithms
CMSC 341 Lecture 21 Graphs (Introduction)
CSE373: Data Structures & Algorithms Lecture 16: Introduction to Graphs Linda Shapiro Spring 2016.
Graph Theory.
Chapter 9: Graphs Basic Concepts
Chapter 11 Graphs.
A Introduction to Computing II Lecture 13: Trees
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS Lecture 17 CS2110 Spring 2018.
Algorithms CSCI 235, Spring 2019 Lecture 32 Graphs I
Chapter 9: Graphs Basic Concepts
Graphs G = (V,E) V is the vertex set.
GRAPHS.
For Friday Read chapter 9, sections 2-3 No homework
Introduction to Graphs
Presentation transcript:

Lecture 13 Graphs

Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the cheapest way to get from Pittsburgh to St Louis? – Electric Circuits Circuit elements - transistors, resistors, capacitors is everything connected together? – Depends on interconnections (wires) If this circuit is built will it work? – Depends on wires and objects they connect. – Job Scheduling Interconnections indicate which jobs to be performed before others When should each task be performed All these questions can be answered using a mathematical object named a “graph” – what are graphs? – what are their basic properties?

Introduction to Graphs Graph – A set of vertices(nodes) V = {v 1, v 2, …., v n } – A set of edges(arcs) that connects the vertices E={e 1, e 2, …, e m } – Each edge e i is a pair (v, w) where v, w in V – |V| = number of vertices (cardinality) – |E| = number of edges Graphs can be – directed (order (v,w) matters) – Undirected (order of (v,w) doesn’t matter) Edges can be – weighted (cost associated with the edge) – eg: Neural Network, airline route map(vanguard airlines)

Paths and Graphs – A path is a sequence of edges from one node to another – A length of a path is the number of edges If w 1, w 2, …, w n is a sequence of vertices such that (w i, w i+1 ) in E, then there is a path of length n-1 from w 1 to w n. what are paths of length 2 in vanguard airlines map? – A simple path is a path where no vertex is repeated first and last vertices can be the same what is an example of a simple path in the vanguard map? What is an example of a non-simple path? – A cycle (in a directed graph) is a path that begins and ends in the same vertex. – i.e. S = {w 1, w 2, …, w n } is a sequence such that w 1 = w n and |S| >1 – A directed acyclic graph (DAG) is a directed graph having no cycles.

More Graph Definitions Connected Graph – A undirected graph is connected if for all (u,v) in V, there exists a path from u to v. – A directed graph is strongly connected if for all (u,v) in V, there exists a path from u to v. – A directed graph is weakly connected if for all (u,v) in V, either (u,v) is in E or (v,u) is in E. Complete Graph – A graph with all nodes connected to each other directly Maximal Edge count – undirected graph |E| max = (n-1) + (n-2) + … = n(n- 1)/2 – directed graph |E| max = n(n-1) Degree – number of edges incident to a vertex – in a directed graph in-degree(sink) - number of edges into vertex out-degree(source) - number of edges from vertex

Some Cardinality Relations For most graphs |E|  |V| 2 A dense graph when most edges are present – E = (|V| 2 ) – A dense graph – large number of edges (quadratic) – Also |E| > |V| log |V| can be considered dense A sparse graph is a graph with relatively few edges – no clear definition – metric for sparsity |E| < |V| log |V| – eg: ring computer network

More About Graphs A graph with no cycles is called a tree. This is a general definition of a tree A group of disconnected trees is called a “forest” A spanning tree of a graph is a subgraph that contains all vertices but only enough of the edges to form a tree. Any additional edge to a tree will form a cycle A tree with V vertices has exactly V-1 edges (induction proof) A C B F D E G A C B F D E G

Graph Algorithms Graphs depend on two parameters – edges (E) – Vertices (V) Graph algorithms can be complicated to analyze – One algorithm might be order (V 2 ) for dense graphs – Another might be order((E+V)log E) for sparse graphs Depth First Search – Is the graph connected? If not what are their connected components? – Does the graph have a cycle? – How do we examine (visit) every node and every edge systematically? – First select a vertex, set all vertices connected to that vertex to non- zero – Find a vertex that has not been visited and repeat the step above – Repeat above until all zero vertices are examined.