l12-graphs

# l12-graphs - CS112 Data Structures Lecture 12 More Graphs...

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

CS112: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 12 CS112: Data Structures CS112: Data Structures Lecture 12 More Graphs

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 2 Lecture 12 Review: Graphs Review: Graphs Generalization of trees Digraph (Directed Graph) Like a tree but any vertex can point to any other Graph like digraph but arcs have no direction
CS112: Slides for Prof. Steinberg ʼ s lecture 3 Lecture 12 Graphs Graphs Generalization of trees Weighted Graph Positive integer weights on each edge 5 9 3 6 1

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 4 Lecture 12 Applications Applications Paths On streets (eg mapquest) Electrical networks On circuit boards Power lines Constraints Ordering constraints on building steps Sudoku
CS112: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 12 Applications Applications Relationships Web page references Friendships (online and real world) Etc, etc, etc

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 6 Lecture 12 Notation Notation Arcs are named by the vertices they connect A B (B,A) or BA
CS112: Slides for Prof. Steinberg ʼ s lecture 7 Lecture 12 Representing Graphs Representing Graphs Adjacency list for each node, linked list of edges public Gnode{ public Edge{ String data; Gnode node; Edge edges; Edge next; Gnode nextNode; } }

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 8 Lecture 12 Representing Graphs Representing Graphs Adjacency list for each node, linked list of edges A B C Nodes data edges nextNode A `` data edges nextNode C `` data edges nextNode B `` node next node next node next
CS112: Slides for Prof. Steinberg ʼ s lecture 9 Lecture 12 Representing Graphs Representing Graphs Adjacency matrix n x n boolean matrix: is there an arc? A B C F F F C T F F B T T F A C B A From \To

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 10 Lecture 12 A B C D Graph Concepts Graph Concepts Neighbors of a vertex: vertices that it shares an arc with Neighbors of A are B and C Degree of a vertex: number of neighbors Degree of A is 2, degree of B is 3
CS112: Slides for Prof. Steinberg ʼ s lecture 11 Lecture 12 A B C D Graph Concepts Graph Concepts In degree (in a digraph): number of vertices that have arcs to this vertex In degree of B is 1 Out degree (in a digraph): number of vertices that have arcs from this vertex Out degree of B is 2

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 12 Lecture 12 Graph Concepts Graph Concepts (Simple) Path Sequence of arcs (A,B),(B,C) May not revisit a vertex (B,A),(A,C),(C,B),(B,D) Except last vertex may = first (B,A),(A,C),(C,B) Vertex A is reachable from B if there is a path from B to A A B C D
CS112: Slides for Prof. Steinberg ʼ s lecture 13 Lecture 12 Graph Concepts Graph Concepts (Simple) Path On digraph must follow arc directions (A,B),(B,D) (A,C),(C,B) A B C D

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

View Full Document
CS112: Slides for Prof. Steinberg
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 11/01/2011 for the course 198 112 at Rutgers.

### Page1 / 60

l12-graphs - CS112 Data Structures Lecture 12 More Graphs...

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

View Full Document
Ask a homework question - tutors are online