Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Discrete Mathematics University of Jazeera College of Information Technology & Design Khulood Ghazal Connectivity Lecture _13.
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,
Graph-02.
Review Binary Search Trees Operations on Binary Search Tree
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Applied Discrete Mathematics Week 12: Trees
Graph & BFS.
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.
Graph COMP171 Fall Graph / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D E A C F B Vertex Edge.
Introduction to Graphs
Graph & BFS Lecture 22 COMP171 Fall Graph & BFS / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D.
1 Section 8.4 Connectivity. 2 Paths In an undirected graph, a path of length n from u to v, where n is a positive integer, is a sequence of edges e 1,
Applied Discrete Mathematics Week 12: Trees
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Fall 2014 Doug James Lecture 17: Graphs.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE Discrete.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Let us switch to a new topic:
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
9.2 Graph Terminology and Special Types Graphs
GRAPH Learning Outcomes Students should be able to:
Graphs CS /02/05 Graphs Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved Definition.
Intro to Graphs CSIT 402 Data Structures II. CSIT 402 Graph Introduction2 Graphs Graphs are composed of ›Nodes (vertices) Can be labeled ›Edges (arcs)
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
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,
Chapter 2 Graph Algorithms.
1 Graphs Chapters 9.1 and 9.2 University of Maryland Chapters 9.1 and 9.2 Based on slides by Y. Peng University of Maryland.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Module #19: Graph Theory: part I Rosen 5 th ed., chs. 8-9 내년 3 월 ? 교환 학생 프로그램 영어 점수 미리미리 준비하세요.
Lecture 10: Graphs Graph Terminology Special Types of Graphs
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 9 (Part 2): Graphs  Graph Terminology (9.2)
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Based on slides by Y. Peng University of Maryland
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.
Graphs What are Graphs? General meaning in everyday math: A plot or chart of numerical data using a coordinate system. Technical meaning in discrete.
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.
9 Graphs. A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes) and E, a set of edges. Each edge has either one or two vertices associated.
COSC 2007 Data Structures II Chapter 14 Graphs I.
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
Chapter 5 Graphs  the puzzle of the seven bridge in the Königsberg,  on the Pregel.
CISC 235: Topic 9 Introduction to Graphs. CISC 235 Topic 92 Outline Graph Definition Terminology Representations Traversals.
Graphs 9.1 Graphs and Graph Models أ. زينب آل كاظم 1.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Graphs Upon completion you will be able to:
1 Graphs Terminology By: Sandeep Tuli Astt. Prof. CSE.
Chapter 9: Graphs.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Chapter 05 Introduction to Graph And Search Algorithms.
Chap 7 Graph Def 1: Simple graph G=(V,E) V : nonempty set of vertices E : set of unordered pairs of distinct elements of V called edges Def 2: Multigraph.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
GRAPH THEORY Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
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.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
1 Graphs Chapters 10.1 and 10.2 University of Maryland Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Graphs Lecture 19 CS2110 – Spring 2013.
Chapter 9 (Part 2): Graphs
Graph theory Definitions Trees, cycles, directed graphs.
Graphs Chapter 11 Objectives Upon completion you will be able to:
CS100: Discrete structures
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
Lecture 10: Graphs Graph Terminology Special Types of Graphs
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS Lecture 17 CS2110 Spring 2018.
Applied Discrete Mathematics Week 13: Graphs
Graphs G = (V,E) V is the vertex set.
GRAPHS.
Presentation transcript:

Discrete Structures CISC 2315 FALL 2010 Graphs & Trees

Graphs A graph is a discrete structure, with discrete components…

Components of a Graph edge vertex (node)

Vertices A graph G = (V, E), where V is the set of all the vertices in the graph, and E is the set of all edges in the graph. The elements of V are typically named u or v.

Types of Edges Undirected edges:  In this case, there is a function f from E to  An edge is a loop if f(e) = {u, u} = {u} for some u in V. Note unordered loop Undirected graph

Types of Edges Directed edges:  In this case, there is a function f from E to  An edge is a loop if f(e) = (u, u) for some u in V. Note ordered loop Directed graph

Graph Terminology Two vertices u and v in an undirected graph G are adjacent (neighbors) in G if {u,v} is an edge of G. If e={u,v}, then the edge e is called incident with the vertices u and v. Edge e is said to connect u and v. Also, vertices u and v are called endpoints of the edge {u,v}.

Graph Terminology u v Vertices u and v are adjacent. Edge e is incident with u and v; e connects u and v. Vertices u and v are endpoints of e. e

Degree The degree of a vertex in an undirected graph is the number of edges incident with it. A loop contributes twice to the degree. A vertex of degree zero is called isolated. A vertex of degree 1 is called pendant.

Graph Terminology u v e What is the deg(u)? What is the deg(v)?

Graph Terminology In a directed graph G with edge (u,v), u is said to be adjacent to v and v is said to be adjacent from u. Vertex u is the initial vertex and v is the terminal (end) vertex of (u,v). The initial and terminal vertices of a loop are the same.

Graph Terminology u v Vertex u is adjacent to v and v is adjacent from u. Vertex u is the initial vertex and v is the terminal vertex of edge (u,v). e

Degree The in-degree of a vertex v, deg - (v) in a directed graph is the number of edges with v as their terminal vertex. The out-degree of v, deg + (v), is the number of edges with v as their initial vertex. A loop contributes 1 to both the in-degree and out-degree.

Graph Terminology u v What is the in-degree of u? the out-degree of u? What is the in-degree of v? the out-degree of v? e

Simple Graphs A graph is simple if it has only one edge connecting each pair of vertices.

Simple Graphs simple not simple

Bipartite Graph A simple graph G=(V,E) is bipartite if V can be partitioned into disjoint sets V 1 and V 2 such that every edge in the graph connects a vertex in V 1 and a vertex in V 2. No edge in G connects either two vertices in V 1 or two vertices in V 2.

Bipartite Graph

Union of Graphs The union of two simple graphs G 1 =(V 1,E 1 ) and G 2 =(V 2,E 2 ) is the simple graph

Union of a Graphs

Matrices Used to represent graphs in a computer program. A matrix is a rectangular array of numbers. a 11 a 12 … a 1n a 21 a 22 … a 2n. a 1m a 2m … a mn A = This is an m x n matrix.

Adjacent Vertices in a Graph g a b c d e f ab,c,d,g ba,d ca,d,e da,b,c,e,f ec,d,f,g f? g? vertex adjacent vertices

Adjacency Matrix to Represent a Graph g a b c d e f abcdefg a b c d e f g

Incidence to Represent a Graph g a b c d e f e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 e8e8 e9e9 e 10 e 11 a b c d e f g e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e8e8 e9e9 e 10 e 11 e7e7

Path A path is a sequence of edges that begins with a vertex of the graph and travels along edges of the graph, always connecting pairs of adjacent vertices. A path of length n from u to v in an undirected graph is a sequence of edges e 1,…,e n that begins with u and ends with v. The path is a circuit if u=v. The path passes through the vertices that are visited, and it traverses the edges on the path. A path or circuit is simple if it doesn’t contain the same edge more than once.

Path in Matrix an Undirected Graph u v

Connectedness An undirected graph is connected if there is a path between every pair of distinct vertices in the graph.

Is this graph connected?

Trees Note that a tree is a connected undirected graph that has no simple circuits.

Path A path of length n from u to v in a directed graph is a sequence of directed edges e 1,…,e n that begins with u and ends with v. The path is a circuit if u=v. The path passes through the vertices that are visited, and it traverses the edges on the path. A path or circuit is simple if it doesn’t contain the same edge more than once.

Circuit in a Directed Graph u=v

Connectedness A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b are vertices in the graph. A directed graph is weakly connected if there is a path between every two vertices in the underlying undirected graph.

Is this graph strongly/weakly connected?

Example Applications of Graphs Designing airplane routes Modeling the interconnections and information flow in local and wide area computer networks Models of ecologies Finding the shortest path between two locations (uses distances along the edges) Solving search problems in artificial intelligence

Lists - revisited A list is a finite ordered sequence of zero or more elements that can be repeated. The difference between lists and tuples is in what parts can be randomly accessed. Head (L) and Tail (L) is Memory representation of a list in the computer bc a e L cons (a,L) d head (L) = b tail (L)

Computer representation of a tree a bcd e a bcd e

Binary Tree a a bc d e bc de Binary trees can be used to represent sets whose elements have some ordering. Such a tree is called a binary search tree and has the property that for each node Of the tree, each element in its left subtree precedes the node element and each Element in its right subtree succeeds the node element.

Spanning Trees – Kruskal’s Algorithm b a c d e f g Kruskal’s Algorithm: 1)Sort the edges of the graph by weight, and let L be the sorted list 2)Let T be the minimal spanning tree and initialize T : = 0. 3)For each vertex v of the graph, create the equivalence class [v] = {v}. 4)while there are 2 or more equivalence classes do Let {a,b} be the edge at the head of L: L := tail (L); if [a} not = [b] then T:= T U {{a,b}}; Replace the equivalence classes [a] and [b] by [a] U [b] fi od L= {{a,b},{c,d},{d,g},{e,f},{f,g},{a,f},{b,c},{c,g},{d,e},{e,g},{a,g},{b,g}} Spanning Tree TEquivalance Classes {}{a},{b},{c},{d},{e},{f},{g} {{a,b}}{a,b},{c},{d},{e},{f},{g} {{a,b},{c,d}}{a,b},{c,d},{e},{f},{g} {{a,b},{c,d},{d,g}}{a,b},{c,d,g},{e},{f} {{a,b},{c,d},{d,g},{e,f}}{a,b},{c,d,g},{e,f} {{a,b},{c,d},{d,g},{e,f},{f,g}}{a,b},{c,d,e,f,g} {{a,b},{c,d},{d,g},{e,f},{f,g},{a,f}}{a,b,c,d,e,f,g}