1 Introduction to Graphs Graph definition / applications Graph terminology –Undirected graphs –Directed graphs –Networks Implementing graphs Reading: L&C.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Graphs CSCI 2720 Spring 2005.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Chapter 8, Part I Graph Algorithms.
Graphs Chapter 30 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
 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.
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Graphs.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Introduction to Graphs
Introduction to Graphs What is a Graph? Some Example applications of Graphs. Graph Terminologies. Representation of Graphs. –Adjacency Matrix. –Adjacency.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Fall 2014 Doug James Lecture 17: Graphs.
Chapter 9: Graphs Basic Concepts
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
Computer Science 112 Fundamentals of Programming II Introduction to Graphs.
Introduction Of Tree. Introduction A tree is a non-linear data structure in which items are arranged in sequence. It is used to represent hierarchical.
Representing and Using Graphs
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Vertices and Edges Introduction to Graphs and Networks Mills College Spring 2012.
Graphs. 2 Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Spring 2007Graphs1 ORD DFW SFO LAX
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.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Graph Terminologies Department of CE/IT M.S.P.V.L.Polytechnic College,
Graphs Upon completion you will be able to:
Chapter 9: Graphs.
Graphs Chapter 28 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Graphs David Kauchak cs302 Spring Admin HW 12 and 13 (and likely 14) You can submit revised solutions to any problem you missed Also submit your.
1 Graph theory Outline A graph is an abstract data type for storing adjacency relations –We start with definitions: Vertices, edges, degree and sub-graphs.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Subject Four Graphs Data Structures. What is a graph? A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes.
Graph theory Definitions Trees, cycles, directed graphs.
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
Refresh and Get Ready for More
Graphs Chapter 11 Objectives Upon completion you will be able to:
Chapter 9: Graphs Basic Concepts
Graphs.
Graphs.
Graph Operations And Representation
Chapter 11 Graphs.
Graph Theory By Amy C. and John M..
Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Graphs.
Graphs.
Graphs.
Important Problem Types and Fundamental Data Structures
Graphs.
Chapter 9: Graphs Basic Concepts
Heaps Chapter 6 Section 6.9.
Presentation transcript:

1 Introduction to Graphs Graph definition / applications Graph terminology –Undirected graphs –Directed graphs –Networks Implementing graphs Reading: L&C 13.1–13.3, 13.5 Course Evaluation

2 Graph Definition/Applications A graph is a non-linear structure w/o any root or parent-child relationships between nodes Graphs can be used to represent: –Communication or transportation networks –State diagrams for finite automata –Prerequisites in a course curriculum AB CD

3 Problems Solved Using Graphs Giving travel directions (Turn right at the gas station, go though two traffic lights, turn left) Determining if the graph is connected or not (“Come to think of it now, there ain’t no way to get there from here” – punchline of a joke) Finding the shortest path across a network (Find me the lowest airfare from Boston to Hawaii)

4 Graph Terminology A vertex is a node in a graph Vertices are named or have a label, e.g. A An edge is a connection between vertices Edges are identified by the pair of vertices that they connect, e.g. (A, B)

5 Undirected Graphs In an undirected graph, the edges have no direction associated with them A connection between vertices A and B can be traversed in either direction Naming an edge (A, B) is the same as (B, A) Two vertices are adjacent if there is an edge connecting them Adjacent vertices are also called neighbors An edge connecting a vertex to itself is called a self-loop or sling

6 Undirected graphs An undirected graph is considered complete if it has the maximum number of edges for its number of vertices A complete graph is also sometimes called a full mesh For n vertices, the number of edges in a complete graph is equal to: n (n - 1) / 2

7 Undirected Graphs A path is a sequence of edges between two vertices The path length is the number of edges An undirected graph is connected if for any two vertices in the graph, there is a path between them If an edge is removed from a graph so that there is no longer a path between any two vertices, we say the graph is partitioned

8 Graph Terminology A cycle is a path with the same first and last vertex and with no repeated edges A graph with no cycles is called acyclic A undirected tree is a sub-class of a graph A undirected tree is a connected, acyclic, undirected graph with one element designated as the root

9 Directed Graphs A directed graph also called a digraph is a graph where the edges are ordered rather than unordered pairs of vertices Edge (A, B) is no longer the same as (B, A) AB CD

10 Networks A network or weighted graph is a graph with a cost or weight associated with each edge The weight may reflect some physical cost of using each edge such as the cost for making a call or the fare for travel between two cities The weight of a path or the path weight is the sum of the weights of the edges in the path Networks may be undirected or directed The weight for any missing edge is infinity

11 Implementing Graphs Adjacency Lists For each node, we maintain a collection of references to the other nodes with which this node shares an edge For a directed graph, the collection contains references to the other nodes that can be reached from this node (reverse edge may not be stored in node at other end) For a network, the collection contains the other node and a weight value for the edge

12 Implementing Graphs Adjacency Matrices Use a two-dimensional array (with weights to represent a network if required) ABCABCD AFTT03Infinity BTFT5026 CTTF320 FT 6 0 D F T F F A B C DF 5 Undirected GraphUndirected Network D

13 Final Exam –See posted day, time, and location –It will be 1-1/2 hours – not 3 hours Watch the website for any late breaking announcements! See the posted practice final exam

14 Course Evaluations Please fill out the course evaluation forms Give to assigned student for turn-in Thank you