Playing with Graphs Alex Andreotti
Countries of Bug World
Countries of Bug World
Countries of Bug World Bugs are stupid: can’t measure length, curving. Tunnels are dark, and bugs can’t see much anyway.
Countries of Bug World Country
Countries of Bug World City
Countries of Bug World City City City City
Countries of Bug World Tunnels
Bug An lives in this country Countries of Bug World Bug An lives in this country
Bug Adam lives in this one Countries of Bug World Bug Adam lives in this one
Can they figure out they live in different countries? Countries of Bug World Can they figure out they live in different countries?
Countries of Bug World An’s Country Jeremy’s Country
Same or Different?
Same or Different?
Same or Different?
Same or Different?
Same or Different?
Same or Different?
Same or Different?
Same or Different?
Countries of Bug World Task 1:Devise a precise description of what it means for two countries to be “the same” as far as the bugs are concerned.
Countries of Bug World Task 2:Julie-Bug says “My country has seven cities and nine tunnels. One city has just one tunnel connected to it, one city has five tunnels connected to it, two cities have three tunnels connected to them, and the other three cities have two connecting tunnels” How many different countries can you draw that fit this description? How can you tell them apart?
Countries of Bug World Graph Theory
Graph Theory Countries Graphs
Graph Theory Countries Cities Graphs Points/Vertices
Graph Theory Countries Cities Tunnels Graphs Points/Vertices Lines/Edges
Graph Theory Graph
Graph Theory Vertex
Graph Theory Vertices
Note: One Vertex, Many Vertices Graph Theory Vertex Vertices Note: One Vertex, Many Vertices
Graph Theory Edges
Graph Theory One Graph…
Graph Theory One Graph…
Graph Theory One Graph…
Graph Theory One Graph…
Graph Theory One Graph…
Graph Theory One Graph…
Graph Theory One Graph…
One Graph, Many Graph Diagrams Graph Theory One Graph, Many Graph Diagrams
Here’s another graph diagram of the same graph Graph Theory Here’s another graph diagram of the same graph
Graph Theory Connected Graph
Graph Theory Disconnected Graph
Disconnected graph is just a collection of connected components Graph Theory Disconnected Graph Component Component Disconnected graph is just a collection of connected components
Diagrams are just one way to represent (some) graphs. Graph Theory Diagrams are just one way to represent (some) graphs.
Graph Theory Other examples: People (vertices), know each other (edges)
Graph Theory Other examples: Tennis players (vertices), played against (edges)
Graph Theory Other examples: Countries (vertices), share a border (edges)
Graph Theory New Rules
Graph Theory New Rules 1. No Loops
Graph Theory New Rules 1. No Loops 2. No multiple edges
Draw all the graphs with 4 vertices. Task 3 Draw all the graphs with 4 vertices.
Task 3 Draw all the graphs with 4 vertices. • • • • Here’s one with no edges
Draw all the graphs with 4 vertices. Task 3 Draw all the graphs with 4 vertices. • • • • • • • • Is there a different graph (not a graph diagram, but a graph), with only one edge?
Draw all the graphs with 4 vertices. Task 3 Draw all the graphs with 4 vertices. • • • • • • • • Same or different?
Task 3 Draw all the graphs with 4 vertices. • • • • • • • • Find all the other graphs in our catalog.
Task 4 Draw all the graphs with 5 vertices. (Hint: there are between 30 and 40. Look for patterns.)
Task 5 Explain the patterns that we find while counting graphs with 1, 2, 3, etc. edges in graphs with n vertices.
Task 6 Device a simplest way to communicate a graph (not a graph diagram, just a graph) over the telephone.
Paths a b g c f e d
Paths a b g c f e d (d, c, …)
Paths a b g c f e d (d, c, b, …)
Paths a b g c f e d (d, c, b, d)
Paths a b g c f e d (f, e, d, b, c)
Paths a • b g • c f e d (e, g, b, a, b, g)
Paths • • • • • • • closed not closed not closed
Paths • • f closed simple not closed simple not closed not simple
Paths not closed not closed closed+simple simple not simple circuit ll g not closed simple not closed not simple closed+simple ll circuit
Trees
Trees Not a Tree Tree
Trees Draw a bunch of trees
Task 7 What is the relationship between the number of vertices and the number of edges in a tree? Why does this relationship hold?
Task 8 Draw all the trees with 5 vertices. Then all the ones with 6. There are between 20 and 30 with 8 vertices. Find them.
Task 9 Which algorithm/method would you use if you had to find all trees with a given number of vertices (say, 12)?
Task 10 Revisit the method we had to communicate a graph over the phone. Do you have a better, simpler one that would work just for trees?
Trees in Graphs
Trees in Graphs A Spanning Tree
Trees in Graphs Can you find another one? How can we count how many there are in a given graph?
Regions in Graphs
Regions in Graphs 1
Regions in Graphs 1 2
Regions in Graphs 1 2 4 3
Regions in Graphs 1 5 2 4 3 The Outside region
(Regions are aka Faces) Regions in Graphs 1 5 2 4 3 (Regions are aka Faces)
Draw several graphs and record the following: Task 11 Draw several graphs and record the following: Number of vertices (v) Number of edges (e) Number of faces (f) Number of vertices in Spanning Tree (A) Number of edges in Spanning Tree (B) Number of edges not in Sp. Tree (C)
Task 11
Task 11 • • • • • v=8 • • •
Task 11 3 1 2 4 5 v=8 e=11 11 6 9 8 10 7
Task 11 5 1 v=8 e=11 f=5 2 4 3
Task 11 • • • v=8 e=11 f=5 A=8 • • • • •
Task 11 7 v=8 e=11 f=5 A=8 B=7 1 2 3 6 4 5
Task 11 v=8 e=11 f=5 A=8 B=7 C=4
Task 11 Draw several graphs and record the following: Number of vertices (v) Number of edges (e) Number of faces (f) Number of vertices in Spanning Tree (A) Number of edges in Spanning Tree (B) Number of edges not in Sp. Tree (C) Do only connected graphs w/o crossing edges
What patterns did you find? Explain why they work. Task 12 What patterns did you find? Explain why they work.
Use your findings to show Task 13 Use your findings to show v – e + f = 2
Euler’s Formula v – e + f = 2
Euler’s Formula “Oiler’s” v – e + f = 2
A graph has 7 vertices and 9 edges. How many faces should it have? Task 13 A graph has 7 vertices and 9 edges. How many faces should it have? Try to draw a graph with 7 v’s and 9 e’s without the requisite number of faces.
Euler’s Formula? • • • •
Euler’s Formula? • • v=4 e=6 f=5 • •
Euler’s Formula? • • v=4 e=6 f=5 • • 4 – 6 + 5 ≠ 2 ???
Euler’s Formula? • • v=4 e=6 f=5 • • “Fake” regions
Euler’s Formula? 4 • • • • v=4 e=6 f=4 3 1 2 • • • • “Fake” regions
Euler’s Formula? v=4 e=6 f=4 4 – 6 + 4 = 2 “Fake” regions • • • • • • 3 1 2 • • • • 4 – 6 + 4 = 2 “Fake” regions
Planar version of same graph Euler’s Formula? • • • • • • • • Non-planar graph Planar version of same graph
Euler’s Formula Non-planar graph Planar version of same graph • • • • • • • • Non-planar graph Planar version of same graph Euler’s only works on planar graphs
Do all graphs have a planar version? Important Question Do all graphs have a planar version? If not, which ones do? • • • • • • • •
Task 14 What happens with Euler’s Formula when a graph is NOT connected? Can you fix it?
n vertices - all connected to each other K Graphs n vertices - all connected to each other
K Graphs • • • • K4
How many edges does K5, K6, Kn have? Task 15 How many edges does K5, K6, Kn have?
Draw K5, both in non-planar, and in planar versions. Task 16 Draw K5, both in non-planar, and in planar versions.
Task 16 Draw K5, both in non-planar, and in planar versions. You are failing at this, aren’t you?
Task 16 Draw K5, both in non-planar, and in planar versions. Let’s see if you can prove it’s not possible
Let’s focus on this face Orders of Faces Let’s focus on this face
Orders of Faces It has 4 edges as boundary we call this the order of the face
Orders of Faces o(f)=4
Orders of Faces o(f)=3
Task 17 Claim 1: Sum of all orders of all faces = 2 x number of edges Draw a bunch of graphs and see if true. Why is it true?
Task 18 Claim 2: 3 x number of faces ≤ 2 x number of edges is true for all (planar) graphs. Try to prove me wrong, find which graphs have 3f=2e, and see if you can understand why my claim is true.
Task 18 Claim 2: 3 x number of faces ≤ 2 x number of edges is true for all (planar) graphs. aka, Every face is at least a triangle
Task 18 Claim 2: 3 x number of faces ≤ 2 x number of edges is true for all (planar) graphs. aka, Every face is at least a triangle (and each edge has two faces - so it’s counted twice)
Task 19 Proving that K5 is not planar: Use Euler’s Formula and 3f≤2e to prove it. (Hint: What do we know about K5?)
Task 20 Draw a planar version of the following graphs, or prove that it’s not possible to do so: v=7, e=17 v=8, e=12 v=7, e=15