{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DSnA8GraphsnBFS

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

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

Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 1 Graphs ARE NOT

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
Intro to Data Structures and Algorithms © Graphs - Introduction, Slide 7 Sub-Graphs 1 2 4 5 3 6 1 2 3 6

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

View Full Document
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
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online