Representing Graphs Wade Trappe.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
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 Slides based on those of Kenneth H. Rosen Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Graphs.
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.
Introduction This chapter explores graphs and their applications in computer science This chapter explores graphs and their applications in computer science.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
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.
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.
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 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,
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:
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
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.
Chapter 5 Graphs  the puzzle of the seven bridge in the Königsberg,  on the Pregel.
Introduction to Graph Theory
Lecture 10: Graph-Path-Circuit
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
 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
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.1 Graphs, Paths, and Circuits.
COMPSCI 102 Introduction to Discrete Mathematics.
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
An Introduction to Graph Theory
Applied Discrete Mathematics Week 14: Trees
CSNB 143 Discrete Mathematical Structures
Graph Theory An Introduction.
Chapter 9 (Part 2): Graphs
Matrix Representation of Graphs
Special Graphs By: Sandeep Tuli Astt. Prof. CSE.
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
Chapter 5 Fundamental Concept
Euler Paths and Circuits
Graph theory Definitions Trees, cycles, directed graphs.
Agenda Lecture Content: Introduction to Graph Path and Cycle
Discrete Structures – CNS2300
Based on slides by Y. Peng University of Maryland
Can you draw this picture without lifting up your pen/pencil?
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Lecture 15: Graph Theory II
G-v, or G-{v} When we remove a vertex v from a graph, we must remove all edges incident with the vertex v. When a edge is removed from a graph, without.
Connectivity Section 10.4.
Walks, Paths, and Circuits
Graph Theory What is a graph?.
Euler and Hamilton Paths
Graphs G = (V, E) V are the vertices; E are the edges.
Section 14.1 Graphs, Paths, and Circuits
5/9/2019 Discrete Math II Howon Kim
Paths and Connectivity
Paths and Connectivity
Graphs, Paths, and Circuits
Based on slides by Y. Peng University of Maryland
Agenda Review Lecture Content: Shortest Path Algorithm
GRAPHS.
Concepts of Computation
Concepts of Computation
Presentation transcript:

Representing Graphs Wade Trappe

Lecture Overview Introduction Some Terminology Paths Adjacency Matrix

Paths and Cycles, pg. 1 Definition: Let v0 and vn be vertices in a graph. A path from v0 to vn of length n is an alternating sequence of n+1 vertices and n edges beginning with v0 and ending with vn, where ei starts at vi-1 and ends at vi. (v0, e1, v1, e2, v2, …, vn-1, en, vn) Example: (1, e1, 2, e2, 3, e3, 4, e4, 2) 3 e2 Length 4 path e3 2 e4 4 e1 7 e6 1 e5 e8 e7 5 6

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. Not Connected 3 e2 e3 2 e4 4 e8 Connected e1 7 e6 1 e5 e7 5 6

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! 2 Another Subgraph 1 A Subgraph 2 1 e1 G 2 1 e1 The entire Graph is a Subgraph! 2 1 A subgraph Without edges

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. 6 (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. 3 e2 e3 2 e4 (6,5,2,4) is a simple path It is not a cycle! 4 e1 7 e6 1 e5 e8 e7 5 6

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. A A B B C D D 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 {v1, …, vn} then Sd(vi) = 2m. Proof: When we sum over the degrees of all the vertices, we count each edge (vi, vj) twice… Once when we count it as (vi,vj) in the degree of vi and then once again when we count it as (vj, vi) in the degree of vi.

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. b a c d e

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 An 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.