DSnA8GraphsnBFS - Graphs ARE NOT Intro to Data Structures...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 1 Graphs ARE NOT
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 2 Graphs V[G] = {1,2,3,4,5,6} |V| = 6 E[G] = {{1,2},{1,5},{2,5},{3,6}} Note: {u,v} = (u,v) = (v,u) (u,v): u v G = (V,E) 1 2 4 5 3 6
Background image of page 2
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 3 Terminology 1 2 5 4 3 6 7 11 10 8 9 Endpoints of an edge Self-loop Neighbors Incidence Parallel edges
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 4 Adjacency List Representation 1 2 5 4 3 1 4 4 3 2 4 5 2 2 1 2 1 4 5 5 5 3 3 2
Background image of page 4
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 5 Adjacency Matrix Representation 1 2 4 3 5 1 0 1 0 0 1 2 1 0 1 1 1 3 0 1 1 0 0 4 0 1 0 1 1 5 1 1 1 0 0 1 2 5 4 3
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 6 Object-Oriented Representation Node: some structure, with all relevant information Edge: name & pointers to two endpoints
Background image of page 6
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 7 Sub-Graphs 1 2 4 5 3 6 1 2 3 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 8 More Terminology Path = a sequence v 1 ,v 2 ,…,v k , v i V s.t. (v i ,v i+1 ) E for every i=1,…,k-1 E.g. <1,2,3,4,5> and <1,2,4> 1 2 5 4 3
Background image of page 8
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 9 Connectivity 1 2 4 5 3 6 Vertices are connected there is a path between them Graph G is connected every 2 vertices are connected Connected Components = maximal connected subgraphs
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 10 Naïve Algorithm 1 Choose a start vertex s V 2 set C := L := {s} 3 while L ≠ φ do 4 choose and remove a node v from L 5 for each edge ( v , w ) E 6 if w C 7 add w to C and to L 8 if |C| < |V| 9 return disconnected 10 else return connected
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/08/2010 for the course ENGINEERIN 50-22-43-2 taught by Professor Prizler during the Spring '10 term at Tel Aviv Uni..

Page1 / 34

DSnA8GraphsnBFS - Graphs ARE NOT Intro to Data Structures...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online