43
GRAPHS Graphs and Digraphs Graph theory is one important aspect in Discrete mathematics. Graphs in this sense have nothing to do with the graphs of functions y = f(x) in the xy coordinate plane. Graphs were first introduced in the eighteenth century. The graphs we are concerned with are like road maps, circuit diagrams of flowcharts in the sense that they depict connections or relationships between various parts of the diagram. Graph theory is the study of directed and undirected graphs. A picture of a graph or diagram consisting of points corresponding to number of V(G), set of vertices, and line segment or arrow corresponding to numbers of E(G). This section aims to: 1. Define and diagram the basic terms of graphs and digraph; and 2. Discuss the application of graphs. A graph denoted by G = (V, E) consists of a finite set V, called the set of vertices (points or nodes) and a set E of unordered pairs of distinct vertices, called the set of edges. If e = {u, v} is an edge of G, we say that e joins u and v and e is incident to u and to v. Illustration. A picture of the graph with set { a, b, c, d, e} and edge set {ab, ac, cb, ad} or {e 1, e 2, e 3, e 4 }. Edge e 1 = {ab} joins a and b which are the endpoints. Vertex f, an isolated point is incident to no edges. See fig. 7.1.1 Note that a graph is sometimes defined as “a simple undirected graph”. Synonyms for “vertex” is “point” and for “edge” is “arc or line”.

Set Theory Graphs

Embed Size (px)

DESCRIPTION

Mathematics

Citation preview

Page 1: Set Theory Graphs

GRAPHSGraphs and Digraphs

Graph theory is one important aspect in Discrete mathematics. Graphs in this sense have nothing to do with the graphs of functions y = f(x) in the xy coordinate plane. Graphs were first introduced in the eighteenth century.

The graphs we are concerned with are like road maps, circuit diagrams of flowcharts in the sense that they depict connections or relationships between various parts of the diagram.

Graph theory is the study of directed and undirected graphs. A picture of a graph or diagram consisting of points corresponding to number of V(G), set of vertices, and line segment or arrow corresponding to numbers of E(G).

This section aims to:1. Define and diagram the basic terms of graphs and digraph; and2. Discuss the application of graphs.

A graph denoted by G = (V, E) consists of a finite set V, called the set of vertices (points or nodes) and a set E of unordered pairs of distinct vertices, called the set of edges.

If e = {u, v} is an edge of G, we say that e joins u and v and e is incident to u and to v.

Illustration. A picture of the graph with set { a, b, c, d, e} and edge set {ab, ac, cb, ad} or {e1, e2, e3, e4}. Edge e1 = {ab} joins a and b which are the endpoints. Vertex f, an isolated point is incident to no edges. See fig. 7.1.1

Note that a graph is sometimes defined as “a simple undirected graph”. Synonyms for “vertex” is “point” and for “edge” is “arc or line”.

A directed graph of simply digraph G = (V, E) consists of a finite nonempty set V, called the set of directed edges. For simplicity, a digraph is a graph with arrows on each edge to indicate direction.

If e = (u, v) is a directed edge of G, then we say that e joins u to v, where u is the tail of e and v is the head of e. We also call e as the incoming edge to v and e is the outgoing edge from u (fig.7.1.2)

Page 2: Set Theory Graphs

Illustration. A picture of the digraph (fig.7.1.3) with vertex {a, b, c} and edge {aa, ab, bc, and cd}. Set of edges may be denoted by {e1, e2, e3, e4,}. In the digraph, edge

e1 = ab joins vertex a to vertex b. The head of the vertex is b and its tail is a. There is also a loop which is an edge e1 = (a, a) from a to itself. The pair of the edges bc and ab are called antiparallel edges. Vertex a has two outgoing edges and one incoming edge.

A path in a digraph G is a sequence of edges such that the terminal vertex of one edge is the initial vertex of the next. Thus, if e1, e2… en are in E(G), v1 e2 v3 v5

Then e1e2 … en is a path provided there are vertices v1, v2, …, vn, vn-1 so that e1 = vivi+1, for i =1, 2, …, n. We say that e1e2 …en is a path of length n from v1 to vn+1. e1 e3 e4

The path is closed if v1 = vn+1.

v1 v4

In Fig. 7.1.4, the sequence e1 e2 e3 e4 is a Fig. 7.1.4path of length 4.

A graph is said to be a simple if there is only a single edge between a pair of vertices and contains no loops. Multigraphs is a path in which there can be more than one edge between a pair of vertices. Sometimes, multigraphs may contain loops.

A graph G1 is a subgraph of another graph G if and only if the vertex and edge sets of G1

are respectively, subsets of the vertex and edge sets of G.

Page 3: Set Theory Graphs

Illustration of Subgraph. Each of the three graphs G1, G2, G3, shown on the right of Fig. 7.1.5 is a subgraph of the graph G. (The subgraphs do not have to be drawn the same way they appear in the presentation of (G).

v2 v3

v1 v1 v7 v1 v2

v2 v7 v2 v3

v1 v7 v4

v3 v5 v6 v4

v5 v7

v4 v6

v5 v6

G G1 G2 G3

Fig. 7.1.5

Illustration. Fig. 7.1.6 depicts a graph G and two subgraphs G1 and G2. The last graph in this figure, G3, is not a subgraph of G because the two vertices of degree 3 in G are not adjacent.

e v

G G1 = {e} G2 = {v} G3 Fig. 7.1.6 In graphis also a vertex in G, every edge in H is also an edge in G, and every edge in H has the same endpoints as in G.

Example 7.1.1 List all nonempty subgraphs of the graph G with vertex set {v1, v2} and edge set {e1, e2, e3} where the endpoints of e1 are v1 and v2, the endpoints of e2 are v1 and v2, and e3 is a loop at v1.Solution. G can be drawn as shown below.

e3

v1

e1

e2

v2

Page 4: Set Theory Graphs

There are 11 nonempty subgraphs of G, which can be grouped according to those that do not have any edges, those that have one edge, those that have two edges, and those that have three edges. The 11 nonempty subgraphs are shown in Fig. 7.1.7.

v1

v2

v1

v2

v1

e1

v2

v1

e2

v2

e3

v1

1 2 3 4 5 6

e3

v1

v2

v1

e1

e2

v2

vi e3

e1

v2

e3

v1

e2

v2

v1 e3

e1

e2

v2

7 8 9 10 11 Fig. 7.1.7

Illustrations. Fig. 7.1.8 is a simple undirected graph; Fig. 7.1.9 is a directed multigraph with loop. Fig. 7.1.10 is a multigraph with a loop.

Fig. 7.1.8 Fig. 7.1.9 Fig. 7.1.10

The degree of a vertex v is the number of the edges incident on it (i.e. the number of the edges for which v as one of the pair of vertices which define the edge). For a diagraph, we have also the indegree and the outdegree of a vertex, the number of edges which terminate on or originated at the vertex respectively. When deg (v) = 0. The vertex is said to be isolated.

Page 5: Set Theory Graphs

Illustration. Deg ¿) = 3, indegree, 2 outdegree 1 (Fig. 7.1.11) In symbols, we write d+¿ ¿ ¿) = 2 (indegree), d−¿ ¿¿) = 1 (outdegree)

Fig. 7.1.11

An edge that is a loop is counted twice. The degree of a vertex can be obtained from the drawing of a graph by counting how many end segment of edges are incident on the vertex. This is illustrated in Fig. 7.1.12

Fig. 9.1.12

Theorem 7.1.1. Let G(V, E) be a simple graph. Where V = { v1, v2 ,… , vn }.Then ,

a) 2 │E │ = ∑i+¿ 1

a

deg v i

b) D1 (G) + 2D2(G) + 3D3(G) + 4D4(G) + … = 2 │ E(G) │

In Fig. 7.1.13, deg v1 = deg v2 = deg v3 = deg v4 = deg v5 Fig. 7.1.13

2 │ E │ = 2(5) = ∑i=1

5

degv1 = deg v1+ deg v2+ … + deg v5

= 2 + 2 + … + 2 = 10

A path in a simple graph is a sequence of vertices ( v0 , v1 ,… , vn ) such that { v i, v i+1 } E for a graph (undirected) (v i, v i+1 ) E for a diagraph

for i = 0, 1, 2, … , n-1.

A cycle in a simple graph is a sequence of vertices ( v0 , v1 ,… , vn ) such that v0=¿ vn. A path or a cycle with no repeated vertices (except the first and the last for a cycle) is said to be elementary path or cycle and a path with no repeated edges or loops is said to be a simple path or cycle.

Page 6: Set Theory Graphs

A Eulerian path is one which traverses every edge in E once and only once. A Eulerian path which is also a cycle is a Eulerian cycle. A Hamiltonian path is one which A Hamiltonian cycle is a cycle which traverses every edge in E exactly once. passes through every vertex of V exactly once.

Illustration. From Fig. 7.1.14, use the following paths and cycle in an indirected graph.Some parts between v1 and v4 : v1 v4

v1 v2v3 v4

Some cycles : v4 v2v3 v4

v4 v5 v3 v4

A Eulerian path : v1 v2v3 v6 v5 v4 v3 v2

A Hamiltonian path : v1 v2v3 v4 v6 v5

No Hamilton cycle

Fig. 7.1.14

In Fig. 7.1.15, we have the Hamiltonian cycle v1 v2v3 v4 v5 v6 v1.

Fig. 7.1.15

In Fig. 7.1.16, we have the paths and cycles in a directed graph

Page 7: Set Theory Graphs

Some paths between v1 and v4 : v1 v2 v3 v4

v1 v3 v4

v1 v5 v4

Some cycles: v1 v2 v3

v1 v5 v4 v3

Eulerian path: v1 v2 v3 v4 v3 v5 v4

Hamiltonian path: v2 v3 v1 v5 v4

Walk, Trail and Circuit We continue the discussion of graph theory by introducing other simple basic terms such as walk, trail, and circuit. Let x , y be (not necessarily distinct) vertices in an undirected graph G= (V,E).An x-y walk in G is a (loop-free) finite alternating sequence x = x0 x1 x2 x3 x4 = y , x0-x4 walk of length 4 of vertices xi and edges ei from G, starting at vertex x0 and ending at vertex y and involving the n edges ei ={xi-1 , xi},where 1 ≤ i ≤ n. The length of this walk is n, the number of edges in the walk. (When n=0, there are no edges, x = y, and the walk is called trivial. These walks are not considered very much in our work). Any x-y walk where x = y (and n > 1 ) is called a closed walk. Otherwise the walk is called open.

1. {a, b}, {b, d}, {d, c}, {c, e},.{e, d}, {d, b} : This is an a-b walk of length 6 in which we find the vertices d and b repeated, as well as the edge {b, d} ( = {d, b} ).

Page 8: Set Theory Graphs

{a, b}, {b, d}, {d, c}, {c, e}, {e, d}, {d, b}, walk from a to b same as {b, d}, {d, e}, {e, c}, {c, d}, {d, b}, {b. a}, walk from b to a

2. b c d e c f (Fig. 7.1.19) : Here we have a b-f walk where the length is 5 and the vertex c is repeated, but no edge appears more than once.

b c d e c f , walk from b to f same as f c e d c b , walk from f to b

Another walk that passes through all vertex is the f-e path f c b a d e

This path is also called a Hamiltonian path since it passes through all vertices exactly once.

3. {f, c}, {c, e}, {e, d}, {d, a} (Fig. 9.1.20) : In this case the given f-a walk has length 4 with no repetition of either vertices or edges.

{f, c}, {c, e}, {e, d}, {d, a}, walk from f to a same as {a, d}, {d, e}, {e, c}, {c, f}, walk from a to f

Finally the edges (b,c), (c,d), (d,a) and (b,a) passes can also call this c-c closed walk (or a-a closed walk or d-d closed walk) {c,e}, {e,d}, {d,a}, {a,b}, and {b,c}, c-c closed walk

Page 9: Set Theory Graphs

Fig. 7.1.21 1

Consider any x-y walk in an undirected graph G = (V, E).1. If no edge in the x-y walk is repeated, then the walk is called x-y trail. A closed x-y trail

is called a circuit.

The example a-b walk {a,b}, {b,d}, {d,c}, {c,e}, {e,d}, {d,b}, is also called a a-b trail because no edge is repeated. However, this is not called a-b path since the vertex d is repeated.

The example b-f walk b c d e c f is also called a-b trail since no edge is repeated. However this is not called a-f path since the vertex c is repeated.

The example b f-a walk {f, c}, {c,e}, {e,d}, {d,a} is called f-a trail and f-a path.

2. If no vertex of the x-y walk occurs more than once, then the walk is called an x-y path. When x = y, the term cycle is used to describe such a closed path.

3. When the cycle passes through all the vertices of the graph G exactly once,then the cycle is called a Hamiltonian cycle.

The c-c closed walk {c,e}, {e,d}, {d,a}, {a,b} and {b,c} is also called b-b cycle since no vertex is repeated. This is called c-c path. This c-c path is not called Hamiltonian path because it did not pass through vertex f. The b-b closed walk {b,c}, {c,d}, {d,a} and {a,b} is a closed path and such is called a cycle.

Exercise 7.1Graphs and Diagraphs

Page 10: Set Theory Graphs

1. (a) If in (v0, v1,…, vn) and v0 = va, then the path is a ____________________.

(b) A Hamiltonian path which is also a cycle is called a __________________.

(c) An _______________ is a graph with vertex 0.

(d) Define a relation R on V by aRb if we can travel from v1 = a to v2 = b using only the roads, we also have bRa. Should all roads under consideration be two way, then R is _____________.

2. In the simple graph indicated below, determine the indegree {denoted by d+ (v) } and outdegree {denoted by d- (v) }.

d+ (a) = ? d+ (d) = 1d- (a) =2 d- (d) =? d+ (b) = 1 d+ (e) = ?d- (b) = ? d- (e) = 1d+ (c) =2 d+ (f) = 0d- (c) = ? d- (f) = ?

3. Draw the graph with V= {v1 v2 v3 v4 v5}, and each pair of distinct vertices is joined by an edge except {v1 v2} and {v3 v4}.

4. Draw the diagraph of G (V, E) with V= {u, v, x, y} and E= {(u, v), (v, x), (x, v), (y, y)}.

5. Draw a simple undirected graph having 3 vertices for which the degrees of the vertices are 1, 2, and 3.

6. Find the simple cycle with 5 edges (the figure is indicated below).

Page 11: Set Theory Graphs

(a) (b)

7. Find the length of a shortest path from x to w in the graphs

8. Find a (a) Euclerian path; (b)Hamiltonian path, (c) Hamiltonian cycle of the following simple graphs.

9. Let G = (V,E) e the undirect graph in fig. 7.1.22. How any paths are there in G from a to h? How many of these paths have length 5?

Fig 7.1.22

Page 12: Set Theory Graphs

Exercise 7.1Graphs and digraphs

1. True or false(a) A graph is a set of points called nodes, with a set of lines called edges connecting some pairs of the nodes _______(b) A Eulerian path is always a Hamiltonian path _______(c) A Hamiltonian path is always a Euleran path _______(d) A loop i an edges _______(e) A diagraph is graph ith arroa on each edge to inclined direction.

_______2. For the graph inclined on right, what are the sets V and E?

3. Draw the graph of G(V,E) with V = { v1 v2 v3 v4 } and

E = [{v1 v2 } , { v3 v4 } , { v1 v3 } , { v2 v4 }]

4. Draw a simple undirected graph having 4 vertices for which the degree of the vertices are 1, 2, 2, and 2.

5. Draw a simple undirected graph having 4 vertices for which the degree of the vertices 2, 2, 2, and 3.

6. Eplain the graph ith the degree equence (4, 4, 4, 3, 2, 1) a hon below:

Page 13: Set Theory Graphs

7. Find the Halmintonian path in the diagraph

8. For the graph in Fig, 7.1.23, determinea. a walk from b to d that is not a trail

b. a b-d trail that is not a path

c. a path from b to d

d. a closed walk from b to b that is not a circuit

e. a circuit from b to b that is not a cycle

f. a cycle from b to b

9. For the graph in Fig. 7.1.23, how many paths are there from b to f? See Ans.

Page 14: Set Theory Graphs

7.2 Isomorphic and Complete Graphs This section aims to:

1. define, distinguish, and illustrate isomorphic, complete and bipartite graphs,and

2. discuss applications of isomorphic and complete graphs.

Two graphs are isomorphic (iso, meaning equal; morph, structure), if they have the same number of vertices and if the vertices of the two graphs may be assigned so that the edge sets are identical.Illustration of two isomorphic graphs is shown in Fig. 7.2.1:

If G1 and G2 are isomorphic graphs, then G1 and G2 have the same number of vertices same number of edges, and same degree sequences

The graph G1 and G3 shown in Fig.7.2.2 are not isomorphic because they have different numbers of vertices.

Fig. 7.2.3 Illustrates two graphs which are not isomorphic: Each group consists of four vertices and four edges, but G2 contains a vertex of degree 1, while G1 has no such vertex.

Illustration. The two graphs indicated in Fig. 7.2.4 are isomorphic with same number of vertices, edges, and degree of sequence.

Page 15: Set Theory Graphs

The two graphs (Fig 7.2.3) illustrates isomorphic with same number of vertices and edges with degree sequence of A,B,C, and D as 3,2,3,2.

Illustration. G and G’ are isomorphic (Fig 3.2.6)

e1 v3

w1 w3

e2 v2 f3 f4

w3

v1 e2 e3 f1 f2 f3

f7 f6

v4 w5 w4

e4

G G’

Fig. 7.2.6

Illustration a) In Fig 7.2.7 G and G’ are not isomorphic because G has nine edges while G’ has only eight.

G Fig. 7.2.7 G’

B) In Fig. 7.2.8 H and H’ are not isomorphic because H has a vertex of degree 4 while H’ does not.

H Fig. 7.2.8 H’A graph is connected, if every distinct vertex u and v in V, there is at least one path

(which could be a single edge) from u to v.A graph is strongly connected if, for any pair of vertices u and v, u ≠ v, there is a

directed path from u and v and another from v to u.

Page 16: Set Theory Graphs

Illustration of Connected GraphThis means that we can find a path from one vertex to another as shown in Fig 7.2.9

a b e g a b e

c d f c d f

Connected graph Disconnected GraphFig 7.2.9 Fig. 7.2.10

Fig. 7.2.10 is not a connected graph because we cannot go to vertex g from any point we start.

Suppose that the vertex V can be partitioned into two disjoint sets V 1 and V 2 such that every edge in E joins a vertex in V 1 to a vertex in V 2 is called a bipartite graph.

Illustration. Fig. 7.2.11 and Fig. 7.2.12 are bipartite graphs.

A simple undirected graph is completedenoted by k n if it has no loops and if, for distinct u and v in V, {u, v} is un E.

A complete graph contains every possible edge between two vertices. A complete graph with n vertices has vertices of degree n – 1. But graph in Fig. 7.2.13 has 4 vertices, each of degree 3,but is not a complete graph.

Page 17: Set Theory Graphs

Illustrations of Complete Graphs

Graphs in which all vertices have the same degree are called regular graphs. As Fig. 7.2.14 shows, 4 regular graphs, with the same number of vertices. But we note thatregular graphs with the same number of vertices need not be isomorphic.

All complete graphs with n vertices are isomorphic to each other.A complete sub graph of a graph is called a clique. The clique number of a graphis the

maximum number of vertices in a complete sub graph of clique of G.

Illustration of Clique GraphsIn Fig. 7.2.15, the following sets of vertices form the cliques, and the clique number of vertices for the graph is 4,{ v1, v2, v7 }, { v2, v5, v7, v8 },{ v2, v7, v8, }, { v2, v8, v5 }, { v5, v7, v8 }

Page 18: Set Theory Graphs

The complete bipartite graph K m, n where m are positive integers is, the graph whose vertex set is the union V= V1 U V2 of the disjoint sets with edge set { uv | u E V1 and v E V2}Illustration. The complete bipartite graph K 2, 3 (Fig. 7.2.16), K 3, 4 (Fig. 7.2.17), and K 3, 3

(Fig. 7.2.18) is

Page 19: Set Theory Graphs

Exercises 7.2Isomorphic and Complete Graphs

1. Determine the degrees of all vertices in the following graphs:(a) K9 (b) K20 (c) K4,6 (d) K10,20

2. All 4 graphs have eight vertices, H1 H2 H3, but none of these is isomorphic to H4. Explain.

H1 H2 H3 H4

3. Which if any of the pairs of graphs as shown figures below are isomorphic? Justify your answer by describing an isomorphism or explaining why one does not exist.

4. Determine whether G and G1 are isomorphic

a. w1 w2

w4 w3

b.

v1 v2 w1 w2

v4 v3 w4 w3

G G1

Page 20: Set Theory Graphs

c.

b v

a c u w

f d z x

c y

G G1

d.

e.

f.

Page 21: Set Theory Graphs

g.

h.

Page 22: Set Theory Graphs

Exercise 7.2Isomorphic and Complete Graphs

1. Graph the following(a) K1 (b) K2 (c) K6 (d) K4, 5

2. a) All regular graphs are complete graphs.b) All complete graphs are regular graphs.c) Is a complete graph contains a Hamiltonian graphs?d) Is a complete graph contains a Hamiltonian path?

3. Give the degree of every vertex of K7; Kn.4. Give the total number of edges of K6; Kn.5. Which of the following graphs are isomorphic? If the graphs are not isomorphic, explain

why not.a.

b.

c.

Page 23: Set Theory Graphs

d.

6. Describe an isomorphism between the two graphs as shown below.

7. Determine whether G and G’ are isomorphic.a.

G G’b.

G G’

Page 24: Set Theory Graphs

c.

G G’

d.

G G’

Page 25: Set Theory Graphs

This section aims to:1. Relate the concept of matrices to graphs; and2. Discuss the application of graphs to matrices.

Adjacency matrix is formed from a square matrix with the number of vertices in rows is equal tothosein columns.The element vi j of the adjacency matrix is the number of edges from v i

to v j . This number in the entry of v i j may either be 1 or 0 for a simple graph but could are either 1 or 0 according as the vertex vij has a loop or none.Two figures (Fig. 7.3.1 to Fig. 7.3.2) displays 2 graphs and their corresponding adjacency matrices.

a. Adjacency matrix of Fig.7.3.1

V1 V2 V3 V4 V5

V1 0 1 0 0 1V2 0 1 0 1 V3 0 1 0V4 0 1 V5 0 Simple Graph Diagraphb. Adjacency matrix of Fig. 7.3.2 Figure7.3.1 Fig.7.3.2

V1 V2 V3 V4 V5

V1 0 1 1 1 0V2 0 1 0 1 0V3 0 0 0 1 1V4 0 0 0 0 1V5 0 0 0 0 1

Let A be the adjacency matrix of a graph G. Then the element in the ith row and jth column of Am is equal to the number of paths of length m from vertex i to vertex j.

We define A2= A .A A3 = A . A2 , or A2 . A

Example 7.3.1. Find the cycle of length 3 in the graph (Fig. 9.3.3.)Solution. We first form the adjacency matrix of Fig. 7.3.3 which is as follows:

V1 to V3 twice 2V2 to V5 only once 1V3 to V5 only once 1V4 to all edges except V3 4V5 to V2 only once 1

Page 26: Set Theory Graphs

0 0 2 0 0 0 0 2 0 0 0 0 0 0 2 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0A2 = 0 0 0 0 1 0 0 0 0 1 = 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 2 2 1 2 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1

Note that in the elements of the matrix A2 :

i) a15 = 2 means that there are 2 paths from v1 to v5

v1 v3 v5 “v1 has to 2 arrows to v5” v1 v3 v5

ii) a42 = 2 means that there are 2 paths from v4 to v2. These are

v4 v5 v2

v4 v5 v2

To obtain the matrix A3:

0 0 0 0 2 0 0 2 0 0 0 2 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1A3 = A2 . A = 0 1 0 0 0 0 0 0 0 1 = 0 0 0 0 1 1 2 2 1 2 1 1 0 1 1 1 3 2 1 5 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 Note that in the elements of the matrix A3:

i) a12 = 2 means that there are 2 paths of length 3 from v1 to v2: ii) a41 = 1 means that there is just one path from v4 to v1, i.e. v4v1. iii) a42 = 3 means thatt there are 3 paths or 3 cycles of lengths 3 from v4 to v2.

Page 27: Set Theory Graphs

These are:

v4 v4 v5 v2 v4

“two ways from v5 to v2” v4 v4 v5 v2 v4

v4 v4 v4 v4 v2

iv) a45 = 5 means that there are 5 paths or 5 cycles of length 3 from v4 to v5.

These are as follows:

v4 v4 v2 v5

“two ways from v2 to v5” v4 v4 v2 v5

v4 v4 v4 v4 v5

v4 v1 v3 v5 “two ways from v1 to v3” v4 v1 v3 v5

Matrices for Graphs

1. Find the digraph with the following adjacency matrices:

a.) 0 1 0 0 0 b.) 0 0 1 0 0 c.) 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0

2. Draw the graphs or multigraphs with the adjacency (i) and (ii).

0 1 0 1 0 1 1 0 1 1 1 1 0 1 0 02 1 1 0 1 1 1 0 1 0 10

0 0(i) (ii)

3. The incidence matrix of a graph G (V,E) without loop is a Boolean Matrix (all entries 0 or 1) with | V | rows and | E | columns such that the (i,j) entry is 1 if vertex i is at one end of edge j and 0 otherwise.

Page 28: Set Theory Graphs

e4

a.) Write the incidence matrix for the following v4 v3

Graph. Call this matrix M.b.) Write the adjacency matrix A for the same e5 e6 e2

Graph. c.) What can you say about the row sums of an v1 v2

Incidence matrix? What about the column e1

sums?

4. Show that two of the graphs with the matrices in Problem 3 are isomorphic.

5. Draw the picture of all connected graphs with 4 edges and 4 vertices. Don’t forget loops and parallel edges.

6. Consider the graph with 5 vertices 1, 2, 3, 4, and 5 and edges {1,2}, {2,3}, {2,4}, {3,4}, {3,5}, and {4,5}.a. Write the adjacency matrix.

b. Compute the matrix which, for all pairs (i,j) of vertices, lists the number of paths of length 2 between them.

c. Compute the number of paths of length 3 between vertices 2 and 3. (This is a single entry from another matrix . Show how you can avoid computing the entire matrix).

d. Explain how to use the adjacency atrix of a simple graph and matrix multiplication to determine the number of triangles incident on any given vertex (i.e., the number of triangles which have the given vertex as one point).

Page 29: Set Theory Graphs

V2V1

V3V4

V1 V2

V3

V4 V5

4

1

2

3

1

2

3

5

44

1 2

3

2

3 4

1

d.)c.)b.)a.)

c.) d.)b.)a.)

Exercises 7.3Matrices for Graphs

1. Give adjacency matrix forthe following graphs and diagraphs :

2. Write the matrices for the following graphs :

3. Are the graphs in Problem 2b and 2c isommorphic ?

4. For the folowing graph, let A be the adjacency matrix. Compute A2 two ways :

a. Directly b. By counting visually the number of paths of

length 2 between each pair of vertices

5. For the graph in problem 4 :a. List all paths of length 4 between u and w. ( The simplest way to record your answer is

to denote each path by its vertex sequence. For instance, one such pathis u vw u w ).b. Check your answer using the adjacency matrix.

7.4 TreesOne particular kind of graph, called a tree, is very important in application to computer

science and other areas. It is useful for studying graphs in general.

Page 30: Set Theory Graphs

Trees was first used in 1847 by Gustav Kirchhoff ( 1824-1887 ) in his work on electrical networks, trees were later redeveloped and named by Arthur Cayley ( 1821-1895 ). In 1857 Cayley used these special graphs order to enumerate the different special trees.

With the advent of digital computers, many new applicationss were found for trees. Special types of trees are prominent in the study of data structures, sorting, and coding theory, in the solution of certainoptimization problems.

This section aims to :1. Define and illustrate trees and enumerate its special classes ; and2. Explore the applications graphs of trees.

Definition7.4.1 Given a ( directed or undirected ) graph G = ( V , E ), let G1 = ( V1 , E1 ) be a subgraph of G. If V1 = V, then G1 is called a spanning subgraph of G.

In graph G of Fig. 7.4.1, neither G1 nor G2 is a spanning subgraph of G. The subgraphs G3 and G4 are bothspanning subgraph of G.

Fig. 7.4.1

Let G = ( V , E ) be a loop-free undirected graph. The graph G is called a tree if G s connected and contains no cycles. A forest is path that contains no cycle.

Fig. 7.4.2 illustratesseven nonisomorphic forest of five vertices, each with more than one component

Fig. 7.4.2In Figure 7.4.3 the graph G1 is a tree, but the graph G2 is not a tree because it contains a

cycle. The graph G3 is not connected, so it cannot be a tree. However, each component of G3 is a tree, and in this case we call G3 a forest.

Page 31: Set Theory Graphs

a b

c

d

ef

(G1)

a b

c

d

e f

(G2)

j q k r m s n p t

u v

w x

y z

(G3)

j q

k r m s n p t u v w x y z

(G4)

Fig 7.4.3

When a graph is a tree we write T instead of G to emphasize this structure. In Fig.7.4.3, we see that G1 is a subgraph of G2 where G1 contains all the vertices of G2 and G1 is a tree. In this situation G1 is a spanning tree for G2. Hence a spanning tree for a connected graph is a spanning subgraph that is also a tree. We may think of a spanning tree as providing minimal connectivity for the graph and as a minimal skeletal framework holding the vertices together. The graph G3

provides a spanning forest for the graph G4.

Illustration of trees with five vertices (Fig 7.4.4). We note that every tree is a forest.

tree: path of length 4K1, 4: tree of path 2

Fig. 7.4.4

A tree other than the trivial tree with only one vertex must contain vertices of degree 1. A tree with more than one vertex contains at least two vertices of degree 1.

Theorem 7.4.1. If a, b are distinct vertices in a tree T = (V, E), then there is a unique path that connects these vertices.

Theorem 7.4.2. If G = (V, E) is an undirected graph, then G is connected if and only if G has a spanning tree.

Theorem 7.4.3. In any tree T = (V, E), │ V │ = │ E │ + 1.

Theorem 7.4.4. The following statements are equivalent for a loop-free undirected graph G = (V, E):

a. G is a tree.

Page 32: Set Theory Graphs

b. G is connected, but the removal of any edge from G disconnects G into two subgraphs that are trees.

c. G contains no cycles, and │ V │ = │ E │ + 1.d. G is connected, and │ V │ = │ E │ + 1.e. G contains no cycles, and if a, b ϵ V with {a, b} not ϵ E, then the graph obtained by

adding edge {a, b} to G has precisely one cycle.f. G has exactly n – 1 edges.g. Given any two vertices u and v in G, there is a unique path from u to v.

Exercises 7.4Trees

Page 33: Set Theory Graphs

1. If G = (V, E) is a loop-free undirected graph, show an example that G is a tree if there is a unique path between any two vertices of G.

2. The connected undirected graph G = (V, E) has 30 edges. What is the minimum value that │ V │ can have?

3. Let T = (V, E) be a tree with │ V │= n ≥ 2. How many distinct paths are there (as subgraphs) in T?

4. Consider the tree given in the figure below.

u y

s t w x v z

(a) Select several pairs of vertices and, for each pair, give all paths connecting them which repeat no edges.

(b) Based on your work in part (a), make a general conjecture about trees.

5. (a) Consider the graph in Problem 4. Here is the vertex sequence for a path from u to z: u t s t v w u v w x z y z. Cut out parts of this path to get an acyclic path from u to z which repeats no edges. Hint: Why visit a vertex twice?(b) Describe a general algorithm which, given a path from a vertex u to vertex v, produces an acyclic path from u to v.

6. Consider the graph in Problem 4.(a) Which edges are parts of cycles? For example, edge t u is part of the cycle t u w v t.(b) Can you make a general conjecture based on this example?

7. Let T1 = (V1, E1), T2 = (V2, E2) be two trees where │ E1 │ = 17 and │ V2 │ = 2│ V1 │. Determine │ V1 │, │ V2 │, and │ E2 │.