




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Class: Combinatorial Computing; Subject: Mathematics; University: Eastern Illinois University; Term: Spring 2009;
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Spring 2009
1
I (^) When working with graphs in a program, we're usually not so much interested in doing some sort of arithmetic operation as we are mainly searching ñ for neighboring nodes, for nodes with the least or maximum degree, etc.
I (^) Given a graph G=(V, E), we can represent G in a computer program either with an adjacency matrix or adjacency lists.
I (^) Either an adjacency matrix or adjacency list can store edge weights rather than 0/1 (indicating edge existence); they can also be used to store directed edges.
2
A A B
B
C
C
D
D
E
E
F
F 0 0 0 0 0 0 1 1 0 1 1
0 1 0 0 0 1 1 1 1 0 0 0 1 0 0 (^1 0 1 ) 0 0 0 0 1
I (^) Notice that in an adjacency matrix, in order to nd a
has any neighbors.
3
A (^) B C E B A C C A B D E D C E A (^) C F F E
as linked lists. I (^) Note that in C++ it is possible to ìshrinkî and ìgrowî array/vector size, thus avoiding wasted space. However, there is a trade off in time.
4
The DREADED Mathematical Induction Proof! (And you thought you'd never see it again ó HA!!)
I (^) Let P(1), P(2),... , P(n), P(n+1),... , be an innite sequence of statements. And suppose we know:
I (^) There are three steps to an Induction Proof:
Use induction to prove:
∑ n i = 1 i^ =^
n ( n + 1 ) 2 ∀^ n^ ^1 BC : IH :
IS :
7
Use induction to prove:
∑ n i = 1 (^2 i^ ^1 ) =^ n
(^2) ∀ n 1
BC : IH :
IS :
8
Use induction to prove: 11 n^ 4 n^ is evenly divisible by 7 ∀ n 0 BC : IH :
IS :
9
I (^) A set of lines is in General Position if no two are parallel and no three pass through the same point.
General Not General Not General
10
Given n lines in general position in the plane, into how many regions is the plane divided?
I (^) Do all sets of 4 lines (in general position in the plane) yield the same number of regions? Why?
I (^) Question : How many new regions seem to get added by the i th^ line? Why? i of them
I (^) Let R(n) be the number of regions formed by n lines in general position in the plane.
I (^) Claim: R(n+1) = R(n) + (n+1)
I (^) Observation: line n+1 passes through n + 1 regions of the plane divided by n lines. Thus , each of these regions is cut in two, for a net gain of n + 1 regions.
BC Let v = 1 One vertex → no edges, e = 0 Thus, clearly true (0 = 1 1 = 0)
IH Assume a tree of n vertices has n 1 edges for some arbitrary n 1.
IS Show a tree Gn + 1 with n + 1 vertices has n edges I (^) Find a vertex of degree 1 (it must be a leaf), and remove it and its edge, forming tree Gn I (^) By the IH, en = vn 1, so Gn + 1 has 1 more vertex than edges (i.e., vn + 1 1 = en + 1 ) I (^) Hence, vn + 1 1 = en + 1 since we add 1 vertex and 1 edge to Gn to construct Gn + 1 Thus, if G is a tree, then e = v 1
End of Subproof
19
IH Assume Euler's formula holds for graphs with n faces, for some arbitrary n 1, i.e., that n = e v + 2
IS Show the formula holds for any connected planar graph G with n+1 faces, v vertices, and e edges (i.e., n+1=e v+2, or n=e v+1)
I Pick a region of G and let a be an edge on that face.
I (^) Then G a has (n+1) 1 = n regions; e 1 edges, and v vertices
a
20
I (^) By the IH: n = (e 1) v + 2 = e v + 1
I Thus, r = e v + 2 ∀ r 1
21
2.1 Euler Cycles
Cycle : a sequence of consecutively linked edges:
((x 1 ; x 2 ), (x 2 ; x 3 ),... , (xn 1 ; xn ))
whose starting vertex is the ending vertex
(x 1 = xn )
and in which no edge can appear more than once.
A vertex may be visted multiple times, however.
22
a
b
c
d
e
f
g
h
i
j
The old Prussian city of Konigsberg, located on the banks of the Pregel River, included two islands which were joined to the banks and to each other by seven bridges:
A
Because sex and television hadn't been invented yet, the townspeople strolled about the town and across the bridges, and had entirely too much time to think...
Eventually, someone tried to determine a walk which began at their front door, crossed each bridge exactly once, and allowed them to return to their front door... A
B C
D
C
A
D
B
They weren't able to do this, so took the problem to the famous and fabulously well respected mathematician, Leonhard “Lenny” Euler!
25
Multigraph : a graph which allows multiple edges between the same vertices, as well as permitting selfñloops.
26
I (^) Can we nd a tour of the bridges which allows us to return home without crossing any bridge more than one time? Why or why not?
I (^) Euler Cycle : a cycle that contains all the edges in a graph and visits each vertex at least once.
27
Let G = (V, E) be a graph. Does G contain a path that begins and ends at the same vertex and traverses each edge exactly once (an Euler Cycle)?
28
Question : If an Euler Cycle exists, does it matter where we start?
Question : Do we need to produce an Euler cycle to know if one exists?
A F
C
E
D
B
I (^) If G has an Euler Cycle, then every vertex has even degree... Why?
I (^) Suppose degree(v) is odd and I (^) we begin at v Can't end there, no way back I (^) we don't begin at v Must end there, contrary to the denition of Euler Cycle
How efcient may depend on what data structure is used to store the edges.
Finding ìnext edgeî in the path could take n = j V j steps, and this happens once for each edge; thus, j V j ∗ j E j steps are required.
37
38
// S - Set of vertices with unmarked edges // P - Euler Path we’re building S = V P = {} fail = false while vertex remains with unmarked edge in S and haven’t failed 1.choose vertex with unmarked edge, u 2."walk" a path P’ to vertex v, marking edges 3.if u doesn’t equal v then fail = true else augment P with P’ endwhile
if not all edges marked, or G not connected, then fail = true
if not fail, then Euler Cycle exists
39
Theorem. An undirected multigraph has an Euler Cycle IFF it is connected and all vertices have even degree.
The proof follows the same construction as we gave for the Euler Cycle on a regular graph:
Take a walk, leaving breadcrumbs as we go.
If we do not return to where we started, yet all the edges we may take are marked, there is no cycle.
Otherwise, if there is a vertex on our path with an unmarked edge, repeat the walk with the same results.
40
In graphs that do not contain Euler Cycles, we must traverse some edges more than one time (called Deadheading edges ) to obtain a tour. (Example in text: street cleaning)
I (^) New Problem : minimize the number of deadheading edges (i.e., nd the minimum set of edges needed to make all vertices of even degree and the graph connected.
I (^) Another Problem : minimize the number of Uñturns and turns the street cleaner must make (takes time and wastes fuel). This same concept is used in VLSI chip design ó minimize layers and vias.
Trail : a sequence of consecutively linked edges in which no edge appears more than once.
Trail is to Path as Cycle is to Circuit
Both trails and cycles allow repeated vertices
Euler Trail : a trail which contains all the edges in a graph. ( Note : it will visit each vertex at least once assuming the graph is connected.)
Corollary (to Euler's Theorem): A multigraph has an Euler Trail, but not an Euler Cycle, IFF it is connected and has exactly two vertices of odd degree.
Proof (⇒) Assume multigraph G has an Euler trail T but no Euler cycle and show it has exactly two vertices of odd degree.
We note the starting and ending vertices of T, the Euler trail, must have odd degree while all other vertices must have even degree (by the same reasoning used to show all vertices in a graph with an Euler Cycle must have even degree). Further, G must be connected.
(⇐) Assume multigraph G has exactly two vertices of odd degree (say p and q ), and show it has an Euler Trail but not an Euler Cycle.
Let us add a supplementary edge < p , q > to G, obtaining the graph H. H is connected and has all vertices of even degree. Hence by the Euler Cycle theorem, H has an Euler Cycle.
Let us call this Cycle C. Now, remove the edge < p , q > from C. This reduces the Euler Cycle to an Euler Trail and includes all edges of G.