let g be a pseudograph with vertex set v, edge set e, and incidence mapping f. let n be a positive...

36
Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex w in G is a sequence e 1 , e 2 , …, e n of edges in E for which f(e 1 ) = {v 0 , v 1 }, f(e 2 ) = {v 1 , v 2 }, …, f(e n ) = {v n-1 ,v n }, for some set of vertices v 0 , v 1 , v 2 , …, v n-1 , v n in V, with v 0 = v and v n = w. (For loops e i , we would have v i-1 = v i , and f(e i ) would be a singleton set) A circuit of length n is simply a path of length n which ends where it started. In the above definition we simply have v = w. A simple path or simple circuit is one in which there are no repeated edges. Some Definitions from 9.4

Upload: margery-blankenship

Post on 26-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

• Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex w in G is a sequence e1, e2, …, en of edges in E for which f(e1) = {v0, v1}, f(e2) = {v1, v2}, …, f(en) = {vn-1,vn}, for some set of vertices v0, v1, v2, …, vn-1, vn in V, with v0 = v and vn = w. (For loops ei, we would have vi-1 = vi, and f(ei) would be a singleton set)

• A circuit of length n is simply a path of length n which ends where it started. In the above definition we simply have v = w.

• A simple path or simple circuit is one in which there are no repeated edges.

Some Definitions from 9.4

Page 2: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Connectedness in Undirected Graphs

• We say that an undirected graph G is connected provided…

Page 3: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

9.7 Planar Graphs

• Definition

• Water, Electricity, Gas

Page 4: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Examples:

Page 5: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Euler’s Formula

Corollaries:• If G is a connected planar simple graph with edge and

vertices, where then

• If a connected planar simple graph has edges and vertices with and no circuits of length three, then

Page 6: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

K5 and K3,3

Page 7: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Kuratowski’s Theorem

Page 8: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

9.8 Graph Coloring

• Planar Dual Graph of a map

Page 9: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Coloring

• Define a coloring of a graph

• Define the chromatic number of a graph

Page 10: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

The Four Color Theorem

• Appel and Haken, 1976

• If there is a counterexample, then there is a minimal counterexample.

• A reducible configuration is a subgraph which cannot occur in a minimal counterexample.

• Appel and Haken proved that every planar graph contains one of 1936 reducible configurations.

• The proof was constructed by a computer program.

Page 11: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Three colors is not enough

• Can you come up with a quick proof of that fact?

Page 12: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Example:

Page 13: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Other Facts

• Since Appel and Haken’s proof, an O(n2) algorithm has been discovered for 4-coloring planar graphs.

• The problem of finding a 3-coloring of a planar graph or deciding such does not exist is NP-complete.

• The problem of finding a 4-coloring of a general (non-planar) graph or deciding such does not exist is NP-complete.

Page 14: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Computing the Chromatic Number

• Can you come up with a simple algorithm for coloring a graph with a reasonably small number of colors?

Page 15: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Applications

• Scheduling rooms, final exams, etc.• Assigning roles in a play• Frequency assignments for TV stations

Page 16: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Example

• There are three meeting rooms in the lodge where the Royal Squid Captains hold their annual convention. Seven meetings are scheduled. There are four officers: The Exalted Octopus, the Revered Clam, the Mighty Sea Bass, and the Mystic Eel. The Exalted Octopus must be present for talks 1, 3, and 7. The Mystic Eel must attend talks 2, 4, and 1. The Revered Clam can’t afford to miss talk 2 or talk 5. Finally, the Mighty Sea Bass must be present for talks 1, 4, and 6. What is the minimum number of time slots needed in which to conduct the meetings, so that each officer will be able to attend all the meetings he must attend?

Page 17: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex
Page 18: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

10.1 Introduction to Trees

• Definition: A tree is a connected undirected graph with no simple circuits

• Theorem: An undirected graph is a tree if and only if any two vertices are joined by a unique simple path.

Page 19: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Rooted Trees

• A rooted tree is a directed graph with all vertices except one having indegree one. The exception is the root, which has indegree zero. All other nodes are accessible from the root via a unique path

• Canonical tree drawing is…

Page 20: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Tree Terms

• Node, parent, child, sibling, ancestor, descendant

• Internal vertex, leaf

Page 21: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Tree Terms, Continued

• m-ary tree, binary tree

• Full m-ary tree

Page 22: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Ordered Trees

• An ordered tree is like a rooted tree, except that an ordering is assigned to the children of every node, so that the terms first child, left child, right child, etc, make sense.

Page 23: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Properties of Trees

• Theorem: A tree with n vertices has n-1 edges

• Theorem: A full m-ary tree with i internal vertices has n = mi+1 vertices

Page 24: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Relationships Between i, n, and l

• Let i, n, and l be the number of internal vertices, the total number of vertices, and the number of leaves, respectively.

• Theorem: In a full m-ary tree, all of the following formulae apply:

a) i = (n – 1)/m and l = ((m – 1)n + 1)/m

b) n = mi + 1 and l = (m – 1)i + 1

c) n = (ml – 1) / (m – 1) and i = (l – 1)/(m – 1)

• In other words, with m fixed, any two of the attributes i, n, and l of a full m-ary tree can be computed given the remaining attribute

Page 25: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Example: Suppose that someone starts a chain letter. Each person who receives the letter is asked to send it on to four other people. Some people do this, but others do not send any letters. How many people have seen the letter, including the first person, if no one receives more than one letter and if the chain letter ends after there have been 100 people who read it but did not send it out? How many people sent out the letter?

Page 26: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Levels

• The level of a node is its distance from the root. The root is at level 0, its children are at level 1, their children are at level 2, etc.

• The height of a tree is the maximum of all the levels of its nodes

• A tree of height h is balanced provided all its leaves are either at height h or height h – 1.

Page 27: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Examples:

Page 28: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Leaves in an m-ary Tree

• Theorem: There are at most mh leaves in an m-ary tree of height h.

• Corollary: If an m-ary tree of height h has l leaves, then . If the tree is full and balanced, then

lh mlog lh mlog

Page 29: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

10.2 Applications of Trees

Page 30: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Binary Search Trees

Maude

Louise

Ken

Isaac

George

Zack

Mary

Page 31: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Decision Trees

Page 32: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

The Complexity of “Compare and Swap” Sorting Algorithms

Theorem: A sorting algorithm based on binary comparisons

requires at least __________ comparisons.

Corollary: The number of comparisons used by a sorting

algorithm to sort n elements based on binary comparisons is

________________.

Page 33: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Prefix Codes and Huffman Encoding

Binary code assigns a bit string to each character. Variable-length code can be used to compress a document- shorter codes for more frequent characters. One example is a prefix code where no code appears as the prefix of another.

Page 34: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

'a' .12'c' .02'd' .08'o' .14'p' .03'r' .11's' .20't' .30

Example of Huffman Coding:

Page 35: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex

Game Trees

Page 36: Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex