Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

CS1022 Computer Programming & Principles Lecture 7.1 Graphs (1)
Chapter 8 Topics in Graph Theory
Chapter 9 Graphs.
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Graph-02.
13 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Section 14.1 Intro to Graph Theory. Beginnings of Graph Theory Euler’s Konigsberg Bridge Problem (18 th c.)  Can one walk through town and cross all.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
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.
1 Section 8.2 Graph Terminology. 2 Terms related to undirected graphs Adjacent: 2 vertices u & v in an undirected graph G are adjacent (neighbors) in.
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
Introduction to Graphs Lecture 18: Nov 16. Seven Bridges of Königsberg Is it possible to walk with a route that crosses each bridge exactly once?
CTIS 154 Discrete Mathematics II1 8.2 Paths and Cycles Kadir A. Peker.
Graphs. Graph A “graph” is a collection of “nodes” that are connected to each other Graph Theory: This novel way of solving problems was invented by a.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Graphs, relations and matrices
Graphs and Euler cycles Let Maths take you Further…
GRAPHS Education is what remains after one has forgotten what one has learned in school. Albert Einstein Albert Einstein Smitha N Pai.
GRAPH Learning Outcomes Students should be able to:
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
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.
Graph Theory Topics to be covered:
CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how.
Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
5.4 Graph Models (part I – simple graphs). Graph is the tool for describing real-life situation. The process of using mathematical concept to solve real-life.
Basic Notions on Graphs. The House-and-Utilities Problem.
Chapter 5 Graphs  the puzzle of the seven bridge in the Königsberg,  on the Pregel.
Introduction to Graph Theory
EASTERN MEDITERRANEAN UNIVERSITY EE 529 Circuit and Systems Analysis Lecture 2 Mustafa Kemal Uyguroğlu.
Lecture 10: Graph-Path-Circuit
Introduction to Graphs. This Lecture In this part we will study some basic graph theory. Graph is a useful concept to model many problems in computer.
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Chapter 6: Graphs 6.1 Euler Circuits
 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.
Basic properties Continuation
Chapter 11 - Graph CSNB 143 Discrete Mathematical Structures.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
CS 261 – Nov. 17 Graph properties – Bipartiteness – Isomorphic to another graph – Pseudograph, multigraph, subgraph Path Cycle – Hamiltonian – Euler.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.1 Graphs, Paths, and Circuits.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
1 Lecture 5 (part 2) Graphs II (a) Circuits; (b) Representation Reading: Epp Chp 11.2, 11.3
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
Graph Theory An Introduction.
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
Chapter 5 Fundamental Concept
Graph theory Definitions Trees, cycles, directed graphs.
Agenda Lecture Content: Introduction to Graph Path and Cycle
Can you draw this picture without lifting up your pen/pencil?
Connectivity Section 10.4.
Walks, Paths, and Circuits
Decision Maths Graphs.
Graph Theory What is a graph?.
Representing Graphs Wade Trappe.
Euler and Hamilton Paths
Graphs G = (V, E) V are the vertices; E are the edges.
Section 14.1 Graphs, Paths, and Circuits
Graphs, Paths, and Circuits
Agenda Review Lecture Content: Shortest Path Algorithm
Presentation transcript:

Representing Graphs Wade Trappe

Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix

Paths and Cycles, pg. 1 Definition: Let v 0 and v n be vertices in a graph. A path from v 0 to v n of length n is an alternating sequence of n+1 vertices and n edges beginning with v 0 and ending with v n, where e i starts at v i-1 and ends at v i. (v 0, e 1, v 1, e 2, v 2, …, v n-1, e n, v n ) Example: (1, e 1, 2, e 2, 3, e 3, 4, e 4, 2) e1e1 e3e3 e2e2 e5e5 e7e7 e6e6 e8e8 e4e4 Length 4 path

Paths and Cycles, pg. 2 Definition: A connected graph is a graph in which we can get from any vertex to any other vertex via a path. Formally, a graph G is connected if given any vertices v and w in G, there is a path from v to w e1e1 e3e3 e2e2 e5e5 e7e7 e6e6 e4e4 Not Connected e8e8 Connected

Paths and Cycles, pg. 3 Obviously, a not-connected graph consists of several pieces. These pieces are subgraphs, or components. Definition: Let G=(V,E) be a graph. We call (V’, E’) a subgraph of G if: For every edge, if e’ is starts at v’ and ends at w’, then Note: You don’t have to include edges! A single vertex is a subgraph! The definition of a subgraph just requires that if you do select an edge, then you must have both ends of it!

Paths and Cycles, pg. 4 There are many choices for subgraphs! 1 A Subgraph 2 Another Subgraph 2 1 e1e1 G 2 1 A subgraph Without edges 2 1 e1e1 The entire Graph is a Subgraph!

Paths and Cycles, pg. 5 Definition: Let v and w be vertices in a graph. –A simple path from v to w is a path from v to w with no repeated vertices. –A cycle is a path of nonzero length from v to v with no repeated edges –A simple cycle is a cycle from v to v in which, except for the beginning and end, there are no repeated vertices. Example: We will look again at the original graph as an example.

Paths and Cycles, pg e1e1 e3e3 e2e2 e5e5 e7e7 e6e6 e8e8 e4e4 (6,5,2,4) is a simple path It is not a cycle! (2,6,5,2,4,3,2) is not a simple path It is a cycle, but is not a simple cycle.

Konigsberg Bridges, pg. 1 Consider two islands lying in the Pregel River in Konigsberg, connected to each other and the river banks. The challenge: start at A,B,C or D and walk over each bridge exactly once then return the start. B D A D BC A D

Konigsberg Bridges, pg. 2 The bridge can be modeled as a graph, where edges are bridges. The Konigsberg Bridge problem is now: Find a cycle in the graph that includes all of the edges and all of the vertices. A cycle in a graph that includes all of the edges and all of the vertices of G is called an Euler Cycle. Note: There are an odd number of edges incident on vertex A… so, if you leave A and come back to A, you use an even amount of vertices… hence, you can’t solve the Konigsberg Bridge problem. The degree of a vertex v, denoted d(v) is the number of edges incident on v. (A loop counts twice).

About the Degree… Sum of all the degrees in a graph is an even #: If G is a graph with m edges and vertices {v 1, …, v n } then  d(v i ) = 2m. Proof: When we sum over the degrees of all the vertices, we count each edge (v i, v j ) twice… Once when we count it as (v i,v j ) in the degree of v i and then once again when we count it as (v j, v i ) in the degree of v i.

Representation of Graphs, pg. 1 Rather than always draw pictures, it is generally useful to have a data-structured representation for graphs. This is where the adjacency matrix A comes in. The row i, column j entry describes the amount of edges that touch node i and node j. a b ed c

Representation of Graphs, pg. 2 The powers of A count the number of paths of various lengths: –The (i,j)-th entry in the matrix A n is the number of paths from i to j of length n. Example: a  d  a and a  b  a gives the 2 a  a paths.