Download presentation
Presentation is loading. Please wait.
1
Graph Theory An Introduction
2
Seven Bridges of Königsberg
Leonhard Euler in 1736 laid the foundations of graph theory. The city of Königsberg in Prussia (now Kaliningrad, Russia) was set on both sides of the Pregel River, and included two large islands which were connected to each other and the mainland by seven bridges. He wished to devise a walk through the city that would cross each bridge once and only once.
3
Sex in America On average, who has more opposite-gender partners, men or women? The University of Chicago interviewed a “random sample” of people over several years to try to get an answer to this question. Their study, published in 1994, and entitled The Social Organization of Sexuality found that on average men have 74% more opposite gender partners than women. ABC News “Primetime Live” found through a survey in 2004 that the average man has 20 partners, and women 6, over their lifetimes, with a claimed 2.5% margin of error. (That’s 233%) What do you think about this? (mathematically)
4
Introduction Informally, a graph is a bunch of dots connected by lines
5
Formal graphs Formally, a graph is a pair of sets (V, E), where:
V is a nonempty set whose elements are called vertices. E is a collection of two element subsets of V called edges. The vertices correspond to the circles in the picture, and the edges correspond to the lines. Thus, the dots and lines diagram above is a pictorial representation of the graph (V, E) where: V = {A, B, C, D, E, F, G, H, I} E = {{A, B} , {A, C} , {B, D} , {C, D} , {C, E} , {E, F} , {E, G} , {H, I}} .
6
Example Graph reprsentation
The above graph is (V, E) where: V = {A, B, C, D, E, F, G, H, I} E = {{A, B} , {A, C} , {B, D} , {C, D} , {C, E} , {E, F} , {E, G} , {H, I}} .
7
Graph Definitions Graphs – networks Vertices – nodes Edges – arcs
Two vertices in a graph are said to be adjacent if they are joined by an edge, and an edge is said to be incident to the vertices it joins. The number of edges incident to a vertex is called the degree of the vertex. Deleting some vertices or edges from a graph leaves a subgraph. Formally, a subgraph of G = (V, E) is a graph G’ = (V ‘ , E’ ) where V ‘ is a nonempty subset of V and E’ is a subset of E.
8
Graph terms Find nodes that are adjacent. What node are incident of C?
What is the degree of A, of F, of G? Define a valid proper subgraph of the graph above.
9
Graph variations In a multigraph, there may be more than one edge between a pair of vertices.
10
Graph variations In a directed graph are arrows pointing to one endpoint or the other.
11
Common Graphs Complete Graph K6 Empty Graph Path with 5 vertices
Cycle with 5 vertices
12
Sex in America Men have 74% more opposite gender partners than women?
Let G = (V, E) be a graph where the set of vertices V consists of everyone in America. Let us partition V into M⊂V (men) and W⊂V (women): What do the edges represent?
13
Sorry guys!! Sex in America
In US |V| = 300 million, |M| = million, |W| = million. A LOT of possible edges! Let Am be average number of male OGPs*, and Aw is average female OGPs Does Am/Aw =1.74? Sorry guys!! So men are having 3% more OGP then women, on average *OGP – Opposite Gender Partnerships.
14
Paths A path is a graph P = (V, E) of the form V = {v1, v2, , vn} E = {(v1 ,v2), (v2 ,v3), ,(vn−1 ,vn)} Similarly, a cycle is a graph C = (V, E) of the form: C = (V, E) of the form E = {(v1 ,v2), (v2 ,v3), ,(vn−1 ,vn), ( vn, v1) }
15
Connectivity A graph is connected if for every pair of vertices u and v, the graph contains a path with endpoints u and v as a subgraph. Not Connected Connected two Connected components one Connected components
16
A Simple Connectivity Theorem
Theorem. Every graph G = (V, E) has at least |V | − |E| connected components. Can you prove it?
17
A Simple Connectivity Theorem
Theorem. Every graph G = (V, E) has at least |V | − |E| connected components. Proof. We use induction on the number of edges. Let P(n) be the proposition that every graph G = (V, E) with |E| = n has at least | | V − n connected components. Base case: In a graph with 0 edges, each vertex is itself a connected component, and so there are exactly |V | − 0 = | | V connected components.
18
A Simple Connectivity Theorem
Inductive step: Now we assume that the induction hypothesis holds for every n-edge graph in order to prove that it holds for every (n + 1)-edge graph, where n ≥ 0. Consider a graph G = (V, E) with n + 1 edges. Remove an arbitrary edge u—v and call the resulting graph G’’ . By the induction assumption, G’’ has at least |V | − n connected components. Now add back the edge u—v to obtain the original graph G. If u and v were in the same connected component of G’’ , then G has the same number of connected components as G’ , which is at least |V | − n. Otherwise, if u and v were in different connected components of G’ , then these two components are merged into one in G, but all other components remain. Therefore, G has at least |V| − n − 1 = | V | − (n + 1) connected components.
19
Distance and Diameter The distance between two vertices in a graph is the length of the shortest path between them. The diameter of a graph is the distance between the two vertices that are farthest apart.
20
Traversing a Graph Can you walk every hallway in the Ascension Hall exactly once? If we represent hallways and intersections with edges and vertices, then this reduces to a question about graphs.
21
Euler Tours and Hamiltonian Cycles
A walk in a graph G is an alternating sequence of vertices and edges of the form: v0, v —v1, v1, v1—v2, v2, , vn−1, vn−1—vn, vn If v0 = vn, then the walk is closed. Walks are similar to paths. However, a walk can cross itself, traverse the same edge multiple times, etc. There is a walk between two vertices if and only if there is a path between the vertices. The entire field of graph theory began when Euler asked whether the seven bridges of Königsberg could all be traversed exactly once.
22
Euler Tours and Hamiltonian Cycles
An Euler walk is a walk that contains every edge in a graph exactly once. Similarly, an Euler tour is an Euler walk that starts and finishes at the same vertex; that is, v0 = vn.
23
Euler tour Theorem. A connected graph has an Euler tour if and only if every vertex has even degree. Corollary. A connected graph has an Euler walk if and only if either 0 or 2 vertices have odd degree.
24
Hamiltonian cycles A Hamiltonian cycle is walk that starts and ends at the same vertex and visits every vertex in a graph exactly once. Determining whether a given graph has a Hamiltonian cycle is “NP complete”.
25
Adjacency Matrices A graph can be represented by an adjacency matrix.
If a graph has vertices v1, , vn, then the adjacency matrix is n × n. The entry in row i, column j is 1 if there is an edge vi —vj and is 0 if there is no such edge. Why is the matrix symmetric? What about a directed graph? What would it mean to have non-zero entries o n the diagonal?
26
Trees A vertex of degree one is called a leaf
A connected, acyclic graph is called a tree. A vertex of degree one is called a leaf Can we add or remove an edge and still have a tree?
27
Trees Theorem. Every tree T = (V, E) has the following properties:
There is a unique path between every pair of vertices. Adding any edge creates a cycle. Removing any edge disconnects the graph. Every tree with at least two vertices has at least two leaves. |V| =| E| + 1.
28
Spanning Trees Every connected graph G = (V, E) contains a spanning tree T = (V, E’ ) as a subgraph
29
Binary Tree A binary tree is a rooted tree in which every vertex has at most two children.
30
Ordered, binary tree In an ordered, binary tree, the children of a vertex v are distinguished. One is called the left child of v, and the other is called the right child. For example, if we regard the two binary trees below as unordered, then they are equivalent. However, if we regard these trees as ordered, then they are different.
31
Problems Prove that the sum of the degrees of the vertices of any finite graph is even. Show that every simple graph has two vertices of the same degree. Show that if n people attend a party and some shake hands with others (but not with themselves), then at the end, there are at least two people who have shaken hands with the same number of people. Prove that a complete graph with n vertices contains n(n − 1)/2 edges.
32
Even degrees Prove that the sum of the degrees of the vertices of any finite graph is even. Proof: Each edge ends at two vertices. If we begin with just the vertices and no edges, every vertex has degree zero, so the sum of those degrees is zero, an even number. Now add edges one at a time, each of which connects one vertex to another, or connects a vertex to itself (if you allow that). Either the degree of two vertices is increased by one (for a total of two) or one vertex’s degree is increased by two. In either case, the sum of the degrees is increased by two, so the sum remains even.
33
Two vertices of the same degree
Show that every simple graph has two vertices of the same degree. Proof: This can be shown using the pigeon hole principle. Assume that the graph has n vertices. Each of those vertices is connected to either 0, 1, 2, , n − 1 other vertices. If any of the vertices is connected to n − 1 vertices, then it is connected to all the others, so there cannot be a vertex connected to 0 others. Thus it is impossible to have a graph with n vertices where one is vertex has degree 0 and another has degree n − 1. Thus the vertices can have at most n − 1 different degrees, but since there are n vertices, at least two must have the same degree.
34
Hand Shaking Show that if n people attend a party and some shake hands with others (but not with themselves), then at the end, there are at least tw Proof: See previous problem. Each person is a vertex, and a handshake with another person is an edge to that person. o people who have shaken hands with the same number of people.
35
Complete Graph Prove that a complete graph with n vertices contains n(n − 1)/2 edges. Proof: This is easy to prove by induction. If n = 1, zero edges are required, and 1(1 − 0)/2 = 0. Assume that a complete graph with k vertices has k(k − 1)/2. When we add the (k + 1)st vertex, we need to connect it to the k original vertices, requiring k additional edges. We will then have k(k − 1)/2 + k = (k + 1)((k + 1) − 1)/2 vertices, and we are done.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.