Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
17 views
Graph Tree
Uploaded by
ronniecraig
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save graph tree For Later
Download
Save
Save graph tree For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
17 views
Graph Tree
Uploaded by
ronniecraig
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save graph tree For Later
Carousel Previous
Carousel Next
Save
Save graph tree For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
BASIC TERMINOLOGY First, we give some termimology ‘that describes: the-vertices and edges of undise graphs. DEFINITION 1. “fwo-vertices e-and v inan undirected graph G are-calicd cent (or neighbors) in G if {u, v}#s an edge of G. Ife= {u,v}, the edge e is iacident with the vertices u and v. The edge w is also éaid-to connect u and vertices u and v.are called endpoints ofthe edge {u, v}. Pe. —— To keep track of how-many edges are cident to a vertex, we make th definition. DEFINITION 2. The degree of-a-vertex in an undirected graph is the Aga with it, except that.a loop at.a vertex contributes twice to of vertex. The degree of the vertex.y Fedenated-by-denQ). we What are the degrees of the vertices int thegraphs Gand-H displayed in Solution: In G, deg(a) =.2, deg(b) = deg(c)= deg(f) = 4, deg(d) = 3, and deg(g) = 0. In H, deg(a) = 4, fap?) = deg(e) = 6, deg(c es: Rt ill wort \LOREM 1 The Handshaking Theorem Let G = (V,E) be an undirected graph wit Then - wd -2e = > deg(v). vev € ede. (Note that this applies even if multiple edges and loops are present.) AMPLE 2 How many edges are there in a graph with 10 vertices cach of degrec 6? iA Solution: Since the sum of the degrees of the vertices is 6 - 10 = 60, it follows tux 2e = 60. Therefore, e = 30. a —_ Theorem 1 shows that the sum of the degrees of the vertices of an undirected grat is even. This simple fact has many consequences, onc of which is given as Theorem 2DEFINITION 4. Ina graph with dirccted edges the in-de; noted by deg” (v), is the number of edges with v as, their term! degree of v, denoted by deg*(v), is the number of edges with v as tal vertex) (Note that a loop at a vertex contributes 1 to both the in-degree and the out-degree of this vertex.) i es Find the in-degree and out-degree of each vertex in the graph G with directed cdyes shown in Figure 2. Solution: The in-degrees in G are: deg” (a) = = 2. deg (hb) = 2, deg"(¢) = 3, deg” (d) = 2, deg™(e) = 3, and. deg-(f) = 0. The out-degrces are: deg*(a) = 4, deg*(b) = 1, deg*(c) = 2, deg*(d) = 2, deg*(e) = 3, and deg*(f) = 0. Fi) Since-each ¢dge has an initial vertex and a terminal vertex, the sum of the in- degrecs and the sum of the out-degrees of all vertices in a graph with directed edges are the sazue. Both of these sume are the number of edges in the graph. This result is stated as dhe following theorem. ” eBwant PARTITE GRAPHS Sometimes a graph has theproperty that its vertex set can be divided into two disjoint subsets such that each edge connects a vertex in one of these subsets to a vertex in the other subsct. For example, consider the graph representing marriages between people avillage, where cach person is represented by a vericx and a marriage is represented by an edge. In this graph, cach edge connects a vertex in the subset of vertices representing maics and a vertex in the subset of vertices representing females. This leads us to the following definition. (LABEFINITION 5. A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint nonempty sets V; and V2 such that every edge in the graph connects a vertex in Vi and a vertex in V2'(so that no edge in G connects either two vertices in V; or two vertices in V2). In Example 8 we Will show that Ce is bipartite, and in Example 9 we will show thai K3 is not bipartite. ES Ce is bipartite, as shown in Figure 7, since its vertex set can be partitioned into the two sets Vy = (v1.3, vs} and V2 = 42, v4. veh and every edge of Ce connects a vertex 17 V, and a vertex in V2. a LEO 7_- Kis not bipartite. To see this, note that if we divide the vertex set of Ks into two disjoint sets, onc of the two sets must corain two vertices. If the graph were bi too” vertices could not be connected by other vertex by an edge. yartite, these LWO- ‘an edge, but in K3 cach vertex is connected to everyREPRESENTING GRAPHS ; he (One way to represent a graph without multiple edges is to list all the edges of this Braph. Another way to represent a graph with no multiple edges is 10 usc adjacency lists, which specify the vertices that are adjigggt t0 each vertex of the graph) VNAMPLE 1 Use adjacency lists to describe the simple graph given in Figure 1. Solution: Table 1 lists those vertices adjacent to each of the vertices of the graph. EXAMPLE 2 Represent the directed graph shown in Figure 2 by listing all the vertices that are the terminal vertices of edges starting at cach vertex of the graph.sc 1 TABLET An Edge List for TABLE 2 An Edge List fora Simple Graph. Directed Graph. \ aa, Vertex | Adjacent Vertices Initial Vertex Terminal Vertices | a e a | bade b : b | bd c © b ace * d a { e e bed _ ke 4. Solution: Table 2 represents the directed graph shown in Figure 2. (AADIACENCY MATRICES Carrying out graph algorithms using the representation of graphs by lists of gdges, or by adjacency lists, can be cumbersoune if there are many edges in the raphe mplify computation, graphs can be represented using matrices. Two types of my cod ede monly used to represent graph: be p We adjacency of vertices, and the other is baéed on incidence of vertices and edges. suppose that G = (V, E)isasimple graph where |V| = n. Suppose that the vertices of listed arbitrarily as 1,2... ra ‘The adjacency matrix A (or Ag) of G, with to this listing of the vertices, is the m X n zero—one matrix with I.as its (, jth pare when v and v, are adjacent, and 0 as its (i, j)th entry when they are not adjacent. In other words; if its adjacency matrix is A = (ai), then ts if tv:. vid is an edge of G, : ai will be presented here. One is based on thiEN AMPLE A EXAMPLES Graph with the m Adjacency Matrix. ¥XAMPLE S HGR a Pscudograph. Use an adjacency matrix to represent the graph shown in Figure 3 Solution: We order the vertices as a,b, c,d. The matrix représenting this graph is arid 1o19)d 1100 1000 3 Draw a graph with the adjacency matrix “fo 1.10 1001 1001 0110 ~ with respect to the ordering of vertices a, b, c, d. Solution: A graph with this adjacency matrix is shown in Figure 4. 0 Adjacency matrices can also be used to represent undirected graphs with loops and with multiple edges. A loop at the vertex a; is represented by a I at the (i, i)th position of the adjacency matrix. When multiple edges are present, the adjacency matrix is no Jonger a zero-one matrix, j, Jyth entry i equals the number of edges iated to {aj, aj). extn undirécted graphs, including mn!:igraphs and pscudographs, have symmetric adjacency miatrices. Use an adjacency matrix to represent the pseudograph shown in Figure 5. Solution: The adjacency matrix using the ordering of vertices a, b, c,d is 0 30 2 3B 011 O11 2)° 2120, : We used zero-one matrices in Chapter 6 to represent directed graphs. The matrix fora directed graph G = (V, £) has a 1 in its (i, j)th position if there is an edge Ata tov, where vy, Yq is an arbitrary listing of the vertices of the directed graph. In uiher words, if = [aj,) is the adjacency matrix for the directed graph with respect '° this hating of the vertices, then a, =[' if Ours an edge of G, © otherwise.XAMPLE 6 7 ane AMPLE 7 INCIDENCE MATRICES ~~ {-Another common way to represent graphs i 9 ueoiRMiiitieg matrices(etG = BE) bean undirected graph. Suppose that v1, v2,..., vs are the vert the edges of G. Then the incidence matrix with r are rveten te edges of han i idee rix with respect to this ordering of V and E is mm = {1 When edge e, is incident with », 0 otherwise. . Represent the graph shown in Figure 6 with an incidence matrix. Solution: The incidence matrix is ca ‘ ce 6 es 6 66 ; oP Late 0°08 080 wees nfo o 1 104 vg {0 0.0. OY ASSL: oa InBie Ore skaeri9 na070 ie [Or te 08 Ae 20 a Incidence matrices can also be used to represent multiple edges and loops. Multiple edges are represented in the incidence matrix using, columns with identical entries, since these edges are incident with the same pair of vertices. Loops are represented vs:n8-¢ column with exactly one entry equal to 1, corresponding to the vertex that is incident ‘with this loop... Represent the pseudograph shown in Figure 7 using an incidence matrix.ENAMPLE { Coa A genealogical chart of the Bernoullis, a famous family of Swiss mathematician shown in Figure I. Such a chart is also called a family tree. A family tree is a where the vertices represent family members and the edges represent. parent: relationships. The undirected graph that represents a genealogical chart is an exi of a special type of graph called a tree. A tree is a connected undirected graph with no simple circu Since a tree cannot have a simple circuit, a tree cannot contain multiple edges orl Therefore any tree must be a simple gruph. Which of the graphs shown in Figure 2 are trees? Solution: G, and G2 are trees, since both are connected graphs with no simple cl s Gj is not a tree because ¢, b, a, d, ¢ is a simple circuit in this graph. Firtally, Gs a tree since it is not connected. phs d Any connected graph that contains no simple circuits is a tee. What about gra cal re Oe taining no simple circuits that are not necessarily connected? These graphs artTHEOREM 1 Nikolaus r (1623-1708), wo was ee ( aaa are ee et ceo aes (0687-1759) (1695-1726) (1700-1782) _ (1710-1790) / \ Johann It —_Jackob IT (1746-1807) _ (1759-1789) FIGURET The Bernoulli Family of Mathematicians. forests and have the property that each of their connected components is a tree. Fig- ure 3 displays a forest. ‘Trees are often defined as undirected graphs with the property that there is a unique simple path between every pair of vertices. The following theorem shows that this. al- ternative definition is equivalent to our definition. ‘An .undirected graph (any.t9 of its vertices. if and:only, if there is. unique aad: path between | Proof: Firstassume that Tis atree. Then Tis a connected graph with no simple circuits. Let x and y be two vertices of T, Since T is connected, by Thegrem | of Section 7.4 there is a simple path between x and y. Moreover, this path must be unique, for if there were a second such path, the path formed by combining the first path from x to.y followed by the path from y to x obtained by reversing the order of,the second path from x to y would form a circuit, This implies, using Exercise 35 of Section 7.4, that there is a Gi t FIGURE? G, and G; Are Treesdescendants of a vertex » are those vertices that have v as an ancestor. A Vencx OF tree is called a leaf if it has no children Vertices that have children are called internal wertlees. The root is an intemal vertex unless itis the only vertex in the graph in which case it is a leaf. If a isa veriex in a tre, the subtree with a as its root is the subgraph of the tree consisting of a and its descendants and all edges incident to these AMPLE 2 Inthe rooted 1ee 7 (with oot) shown in Figure 5 find he parent of he She ot : w~*t the siblings of h, ull ancestors of ¢, all descendanis: ‘of b, all internal vertices, and all leaves. What is the subtree rooted at g? and j. The siblings of h are of b are c, d, and. The k,l, and m. The subtree a s Solution; ‘The parent of ¢ is b, The children of g are fi, i and j. The ancestors of e are c, b, and a. The descendants internal vertices are a, b, c, g, h, andj, The leaves are d, €, fds rooted at g is shown in Figure 6. .ét their internal vertices have the same num- ations. Later in this chapter we will and coding. Rooted trees with the property that all ber of children are used in many different applic: use such trees to study problems involving searching, sorting, IN 2. ‘A rooted tree is called an m-ary tree if every internal vertex has Idren, The tree is called a fill m-ary tree if every internal vertex rary tree with m = 2 is called a binary tree. ‘clemouly lowe, atmos A chtldrew & Hee Since eck chemi ow a brow Vee have, 2. childven , left se eee wget a. DEFINITIO! no more than m chil hhas exactly m children. ‘An m- P tree chose called a binoy Bioauny Tree eof ™ a ‘ i FIGURES A Rooted Tree 7. FIGURE 6 The Subiree Rooted Atg-
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6125)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2619)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel