Graphs Today’S Announcements
Total Page:16
File Type:pdf, Size:1020Kb
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 MYTH Graph of greek mythological figures CHAOS s tie dei ial rd EREBUS rimo p ER OS NYX GAEA PO NTUS SIS NEME S CER OS MORO ER THANAT HEMERA AETH URANUS S AN TIT HEA IAP T ETUS RION HYPE E NOSYN OCEA MNEM NUS T IS ETHYS S THEM COEU E EURYBIA PHOEBE ELEN CREUS DIONE S RHEA CRONOS LIOS HE NER PROM EOS EUS ETHEUS TH AUMA S PERSE DOR IS M PALL LETO ETIS AS ERIS STYX INACHUS ME ADES LIA POSEIDON HESTIA H HERA ZEUS SEA PLEION GO E ELEC DS TRA ST & N YX CE ym p CIR hs AE DEMETER SIPH S PA PERSE P IANS OLYM WELVE EON - T S DOD EKATH USE M CHAR ON CLY MNE ARION PERSEPHONE GALAT IOPE EA P CALL ROTO CLIO AG ATHENA APHRODITE LIA AVE A HEBE ARES IA THA MPHITRIT URAN E IR DIKE IS B ARTEMIS IA NIKE APOLLO AE IO A THRA S TLAS IUS AGRU THEST OE ACRISIUS AGEN OR TELEPHASSA CYRENE REUS AM TYNDA BROS TRITON IA E LEDA UDOR M HEUS A PH AIA ORP YTO ERYT HEA PHOENIX EUROPA RO HESPE MULUS REMUS DS RIA GO EMI EMENE & D ALC ANS DANAE HUM MONIA DIOMEDES HAR STOR S CA ENELAU N M HELE ERACLES ERSEUS H P DRYOPE HERMES MINOS SEMELE RMIONE HE US SYMAETHIS PAN ARIADNE DIONYS ACIS LATRAMYS LEGEND OF THE MYTH FAMILY IN THE MYTH FATHER MOTHER ZEUS Zeus CHILDREN DE IS METER THEM HERA MAIA DIONE SEMELE LETO COLORS IN THE MYTH PRIMORDIAL DEITIES TITANS SEA GODS AND NYMPHS DODEKATHEON, THE TWELVE OLYMPIANS OTHER GODS PERSE PHONE HEBE TEMIS DIKE MUSES ARES HERMES ATHENA APHRODITE DIONYSUS APOLLO AR E GODS OF THE UNDERWORLD UROPA D ANAE ALCEMENE LEDA MNEMOSYNE ANIMALS AND HYBRIDS HUMANS AND DEMIGODS circles in the myth 196 M - 8690 K {Google results} M 8690 K - 2740 K INOS CALLIOPE PERSEUS HERACLES HELEN URANIA THALIA CLIO 2740 K - 1080 K 2 / 8 1080 K - 2410 J. KLAWITTER & T. MCHEDLIDZE Graph definition A graph is a pair of sets: G = (V ; E). I V is a set of vertices: fv1; v2;:::; vng. I E is a set of edges: fe1; e2;:::; emg where each ei is a pair of vertices: ei 2 V × V . A C V = fA; B; Cg B E = f(A; B); (B; A); (C; B)g 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) = fuj(u; v) 2 Eg b a c 8 9 Edges incident to v: I (v) = f(u; v)ju 2 N(v)g e d g f 6 7 o Degree of v: deg(v) = jI (v)j 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) 2 E 0 then u; v 2 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 vertices n m 4 5 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) = 2jEj v2V 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.