l12-graphs

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

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

View Full Document Right Arrow Icon
CS112: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 12 CS112: Data Structures CS112: Data Structures Lecture 12 More Graphs
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
CS112: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 12 Applications Applications Relationships Web page references Friendships (online and real world) Etc, etc, etc
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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; } }
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
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
Background image of page 13

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

View Full DocumentRight Arrow Icon
CS112: Slides for Prof. Steinberg
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online