Copyright © Curt Hill 2001-2006 Graphs Definitions and Implementations.

Slides:



Advertisements
Similar presentations
Cpt S 223 – Advanced Data Structures Graph Algorithms: Introduction
Advertisements

Introduction to Graph “theory”
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
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.
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.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
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.
Chapter 9: Graphs Basic Concepts
Balanced Binary Search Trees height is O(log n), where n is the number of elements in the tree AVL (Adelson-Velsky and Landis) trees red-black trees get,
Graph. Data Structures Linear data structures: –Array, linked list, stack, queue Non linear data structures: –Tree, binary tree, graph and digraph.
Been-Chian Chien, Wei-Pang Yang, and Wen-Yang Lin 6-1 Chapter 6 Graphs Introduction to Data Structure CHAPTER 6 GRAPHS 6.1 The Graph Abstract Data Type.
Intro to Graphs CSIT 402 Data Structures II. CSIT 402 Graph Introduction2 Graphs Graphs are composed of ›Nodes (vertices) Can be labeled ›Edges (arcs)
Computer Science 112 Fundamentals of Programming II Introduction to Graphs.
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,
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Graphs. What is a graph? A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes to each other The set of.
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.
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.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Graphs. 2 Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Graphs CSE 2011 Winter June Graphs A graph is a pair (V, E), where  V is a set of nodes, called vertices  E is a collection of pairs.
Spring 2007Graphs1 ORD DFW SFO LAX
GRAPHS THEROY. 2 –Graphs Graph basics and definitions Vertices/nodes, edges, adjacency, incidence Degree, in-degree, out-degree Subgraphs, unions, isomorphism.
COSC 2007 Data Structures II Chapter 14 Graphs I.
Lecture 5.4: Paths and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
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. Introduction Graphs are a collection of vertices and edges Graphs are a collection of vertices and edges The solid circles are the vertices A,
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
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.
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,
Graphs Upon completion you will be able to:
Chapter 9: Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
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.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
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.
Graphs.
Introduction to Graphs
Basic Concepts Graphs For more notes and topics visit:
CS 367 – Introduction to Data Structures
Introduction to Graphs
CS120 Graphs.
Constructing and Using
Refresh and Get Ready for More
Graphs All tree structures are hierarchical. This means that each node can only have one parent node. Trees can be used to store data which has a definite.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Chapter 9: Graphs Basic Concepts
Graphs.
Graph Operations And Representation
Graph Theory By Amy C. and John M..
Graphs.
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
CSC 380: Design and Analysis of Algorithms
Chapter 9: Graphs Basic Concepts
Graphs G = (V,E) V is the vertex set.
GRAPHS.
Heaps Chapter 6 Section 6.9.
Introduction to Graphs
Introduction to Graphs
Presentation transcript:

Copyright © Curt Hill Graphs Definitions and Implementations

Copyright © Curt Hill Mathematical definitions Nodes or Vertices –A location or point –May have a number of properties Arcs or Edges –Connector of nodes –Directional or bidirectional –May also have other properties, eg. cost

Copyright © Curt Hill Mathematical definitions Indegree of a node –Number of arcs ending at node Outdegree –Number of arcs starting at node Directed or digraph –Arcs are one directional only Undirected –Bidirectional graphs –Node indegree = node outdegree

Copyright © Curt Hill Undirected graphs Two nodes are adjacent if an arc connects them A path is a collection of arcs leading from one node to another A cycle is a path of at least three arcs that starts and ends on the same node A graph is connected if there is a path from any node to any other A disconnected graph contains components

Copyright © Curt Hill Directed graph Each arc must start at a node and finish at a node –Usually a different node, but self references are possible Each node may point at zero or more arcs Each node may be pointed at by zero or more arcs Since pointers are one directional, all pointer based structures are digraphs

Copyright © Curt Hill Directed graphs again Also has the notion of paths and cycles A strongly connected digraph has a path from every node to every other node A weakly connected digraph has a path from every node to every other node, only if converted to an undirected graph

Copyright © Curt Hill Connectivity A and B together are a disconnect graph with two components A is strongly connected B is weakly connected A B

Copyright © Curt Hill Real Graphs Which of following are directed? Airline/bus/train routes Highway, roads, streets Flow graphs of programs Circuit board component connections Moves in games or puzzles Molecule diagrams People with a “works with” relationship People with a “works for” relationship Rooms of a building

Copyright © Curt Hill Flow Graphs 2: a = b * 2; 3: while(b < 4) { 4: c += a/2 + b--; 5: if(a<0) 6: a = -a*2 + 1; 7: } 8: a = 0;

Copyright © Curt Hill Previous Data Structures Any pointer based data structure is graph A straight singly linked list has indegree one –Outdegree one for every node except last Circular singly linked list has all nodes with indegree=outdegree=1 A doubly linked list increases degrees to two All doubly linked and circular lists contain cycles

Copyright © Curt Hill Implementations Is a pointer based structure the obvious way to implement graphs? The problem is the maximum outdegree –If too large then each node has too many pointers –Many of which may be null Suppose the average outdegree is 2 but the maximum is 20 –How would you implement?

Copyright © Curt Hill Set Representation Set of destinations –Each node contains a set of those nodes that are connected by an arc 7: {8, 9} 8: {9} Sets of ordered pairs –First is source, second is destination {(7,8),(7,9),(8,9)} 8 9 7

Copyright © Curt Hill Adjacency Matrix Matrix contains booleans or weights A sparse matrix can be a list of lists