<<

Graphs Today’s announcements:

I PA3 out, due 29 March 11:59p

I Final Exam, 12 April 7:00p, SRC A & B

Today’s Plan 0 0 6 1 I Graph representation 5 1

I Graph terminology 5 2 Division 4 2 1. Start at vertex 0 and leading digit. 3 4 3 2. At digit d, follow d black edges and then one red edge, and move to next digit. Repeat. 3. Divisible by 6 (or 7) iff end at vertex 0.

1 / 8 Greek gods Graph of greek mythological figures

CHAOS

s itie l de rdia EBUS imo ER pr E ROS GAEA

PO NTUS

IS NEMES CER ERA HEM

S AN TIT

THEA IAPE TUS ERION HYP YNE EMNOS OCEANU MN S TET EMIS HYS EUS TH EU EBE CO NE RYBIA CREU IONE PHO SELE S CRONOS D S HELIO PR NERE OMET US HEUS

THAUM AS RSE D PE ORIS

STYX ME ADES LIA H SEA PLEION GO E ELEC DS TRA ST & N YX CE ym p CIR hs AE SIPH S PA

P IANS E OLYM TWELV THEON - ES DOD EKA US M C LYMN E ARION G ALATEA LIOPE PR CAL OTO DITE AGAV APHRO HALIA E AMP ANIA T HITRITE E UR IS DIK LLO ARTEM APO AETHR ATL A RUS AS ESTIUS OEAG TH IUS ACRIS TELEPHASSA CYRENE

S DAREU AMB TRI TYN ROSIA TON EUD LEDA S ORA RPHEU PHYT O O ERY THEA RO HESPE MULUS REMUS DS RIA GO EMI MENE & D ALCE ANS DANAE HUM MONIA HAR

OR CAST NELAUS ME HELEN ACLES EUS HER PERS DRYOPE

RMIONE HE

US SYMAETHIS DIONYS

ACIS LATRAMYS

LEGEND OF THE MYTH

FAMILY IN THE MYTH FATHER MOTHER ZEUS Zeus

CHILDREN DEMETER HERA MAIA SEMELE LETO COLORS IN THE MYTH PRIMORDIAL DEITIES SEA GODS AND DODEKATHEON, THE OTHER GODS PERSE PHONE HEBE TEMIS ARES HERMES ATHENA AR

GODS OF THE UNDERWORLD EUROPA DANAE ALCEMENE LEDA ANIMALS AND HYBRIDS HUMANS AND DEMIGODS

circles in the myth 196 M - 8690 K {Google results} M 8690 K - 2740 K INOS HELEN CLIO 2740 K - 1080 K 1080 K - 2410 2 / 8 J. KLAWITTER & T. MCHEDLIDZE Graph definition A graph is a pair of sets: G = (V , E).

I V is a set of vertices: {v1, v2,..., vn}.

I E is a set of edges: {e1, e2,..., em} where each ei is a pair of vertices: ei ∈ V × V . A C V = {A, B, C} B E = {(A, B), (B, A), (C, B)} If each edge is an ordered pair (i.e. (A, B) 6= (B, A)) then the graph is directed otherwise undirected.

3 / 8 Graph vocabulary Vertices adjacent to v: N(v) = {u|(u, v) ∈ E} b a c 8 9 Edges incident to v: I (v) = {(u, v)|u ∈ N(v)} e d

g f 6 7 o Degree of v: deg(v) = |I (v)|

n m 4 5 l Path: Sequence of vertices connected by edges k j 2 3 i h 0 1 Cycle: Path with same start and end vertex p q

Simple graph: No self-loops or multi-edges

4 / 8 Graph vocabulary Subgraph of G = (V , E): (V 0 ⊆ V , E 0 ⊆ E) b and if (u, v) ∈ E 0 then u, v ∈ V 0 a c 8 9 e d Complete graph: Maximum number of edges

g f 6 7 o Connected graph: Path between every pair of n m 4 5 vertices l k j 2 3 Connected component: Maximal connected i subgraph h 0 1 p q Acyclic graph: no cycles

Spanning tree of G(V , E): Acyclic, connected graph with vertex set V 5 / 8 Graph Vocabulary: Use the previous graph to answer

1. List the edges incident to vertex b: 2. What is the degree of vertex d? 3. List the vertices adjacent to vertex i: 4. Give a path from 0 to 7: 5. Give a path from k to h: 6. List the vertices in the largest complete subgraph in G: 7. How many connected components are in G? 8. How many edges in a spanning tree of each component? 9. How many simple paths connect 0 and 9? 10. Can you draw G with no edge crossings?

6 / 8 Graph properties

How many edges in a simple connected graph on n vertices? Minimum Maximum In a non-simple, non-connected graph on n vertices? Minimum Maximum Handshaking Theorem: If G = (V , E) is an undirected graph, then X deg(v) = 2|E| v∈V

Corollary An undirected graph has an even number of vertices of odd degree.

7 / 8 Topological Sort A topological sort is a total order of the vertices of a directed graph G = (V , E) such that if (u, v) is an edge of G then u appears before v in the order.

belt x y watch means x before y socks

shoes

pants

shirt boxers

Topological Sort Algorithm I 1. Find each vertex’s in-degree (# of inbound edges) 2. While there are vertices remaining 2.1 Pick a vertex with in-degree zero and output it 2.2 Reduce the in-degree of all vertices it has an edge to 2.3 Remove it from the list of vertices Runtime? 8 / 8