Docsity

Basic Graph Theory - Computer Architecture | CPSC 5155U, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
Basic Graph Theory
Graph theory provides a mathematical structure that is convenient
for understanding a number of problems and writing algorithms to solve them.
At one level, graphs are very simple. They are just dots connected by lines.
The “dots”, generally drawn as labeled circles, are called “vertices” (singular is “vertex”)
or “nodes”. The lines are usually called “edges”, but may be called “links” or “arcs”.
The vertices are generally labeled by positive integers, but can be labeled otherwise.
In a graph that is read as a map, many of the vertices are labeled with city names.
One special class of graphs is called “trees”, to be defined soon.
For some reason, we tend to use the term “node” when discussing trees
and use the term “vertex” when discussing general graphs.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c

Partial preview of the text

Download Basic Graph Theory - Computer Architecture | CPSC 5155U and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Basic Graph Theory

Graph theory provides a mathematical structure that is convenient for understanding a number of problems and writing algorithms to solve them. At one level, graphs are very simple. They are just dots connected by lines. The “dots”, generally drawn as labeled circles, are called “vertices” (singular is “vertex”) or “nodes”. The lines are usually called “edges”, but may be called “links” or “arcs”. The vertices are generally labeled by positive integers, but can be labeled otherwise. In a graph that is read as a map, many of the vertices are labeled with city names. One special class of graphs is called “trees”, to be defined soon. For some reason, we tend to use the term “node” when discussing trees and use the term “vertex” when discussing general graphs.

Definition of a Graph

We present two definitions of the mathematical object called a graph. Definition 1: A graph is a finite subset of the positive integers, denoted by V = { 1, 2, …, N }, for N  1, and a possibly empty subset E  V  V. WOW! That is a lot of help. Definition 2: A graph G is a finite non-empty set of objects called vertices (the word “vertices” is the plural of “vertex) together with a (possibly empty) finite set of pairs of distinct vertices of G called edges. The vertex set is commonly denoted by V(G) = {1, 2, 3, …, N}, where N is the number of vertices in the set. It is convenient to use integers to label vertices. The edge set, commonly denoted by E(G), is a subset of (V(G)  V(G)), the set of all pairs of elements from the vertex set V(G). The cardinality of the vertex set of a graph G is called the order of G. The cardinality of the edge set is called the size of G. Commonly |E(G)| = M. An (N, M)-graph G is a graph with N vertices and M edges.

Example: V(G) = {1, 2, 3, 4}

V(G)  V(G) = { (1, 1), (1, 2), (1, 3), (1, 4),

(4, 1), (4, 2), (4, 3), (4, 4) }. This set has 16 elements. A directed graph with vertex set V(G) would have its edge set as a subset of the following subset of V(G)  V(G). { (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3) }. |E(G)|  12. An undirected graph with vertex set V(G) would have its edge set as a subset of the following subset of V(G)  V(G). { (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4) }. |E(G)|  6.

Representations of Graphs

So far, we have followed the strict mathematical definition of a graph. The problem is that most people (your instructor included) prefer a visual depiction of these mathematical objects. With the understanding that these depictions can occasionally be misleading, as we shall show later, we now begin with the simpler depictions. An (N, M)–graph G is depicted with N circles denoting the N vertices and M lines connecting the circles and representing the edges. Labeled Graphs: While we often use subsets of the set of integers to denote the vertices in a graph, we note that this is just a convenience. A four–vertex graph might have the vertex set {Atlanta, Memphis, Miami, Tampa}. As examples, let’s look at representation of some graphs on four vertices. V(G) = {1, 2, 3, 4}.

Some Undirected Graphs

Let’s examine three undirected graphs with four vertices and three edges. Two of the graphs are connected; the one at the right is disconnected. E(G) = { (1,2), (1, 3) E(G) = { (1, 2), (1, 4), E(G) = { (1, 2), (1, 4) (1, 4) } (2, 3) } (2, 4) } Here are a number of undirected graphs on three vertices.

Some Directed (4, 3)–Graphs

Here are two (4, 3) directed graphs. Note that they are different graphs. E(G1) = { (1, 2), (1, 4), (4, 3) } E(G2) = { (1, 4), (2, 1), (4, 3) } Note specifically that (1, 2)  E(G1) but (1, 2)  E(G2). also (2, 1)  E(G1) but (2, 1)  E(G2) In the directed graph, the edges are ordered pairs taken from the set V(G)  V(G). For this reason (1, 2)  (2, 1).

Still More on Directed and Undirected Graphs

Consider the following two graphs, one directed and one undirected. In what sense are they similar? Each graph has V(G) = {1, 2, 3, 4} The undirected graph has E(G) = { (1, 2), (1, 4), (2, 3), (3, 4) } more conventionally written as E(G) = { (1, 2), (2, 3), (3, 4), (4, 1) }. The directed graph has E(G) = { (1, 2), (2, 3), (3, 4), (4, 1), (1, 4), (4, 3), (3, 2), (2, 1) } The undirected graph can be seen as a simpler representation containing the same information as the directed graph. Nevertheless, they are not the same graph.

Equivalence of Undirected and Directed Graphs

For every directed graph, there is an undirected graph that has a similar structure. These graphs are not equivalent. In some cases, the structure of the underlying undirected graph may yield insights into the structure of the directed graph. The main use of this concept arises when we discuss the idea of connectivity in directed graphs. While the idea of a connected graph is intuitive, we shall wait a while before giving a formal definition.

Complement of a Graph

Let G be an (N, M)–graph with vertex set V(G) = {1, 2, …, N} and edge set E(G). The complement of graph G , denoted GC, is defined to be the graph with vertex set V(GC) = V(G) and edge set E(GC) defined by e  E(GC) if and only if e  E(G) Example: Define G by V(G) = {1, 2, 3, 4} and E(G) = {(1, 2), (1, 3), (1, 4)} Then GC is defined by V(GC) = {1, 2, 3, 4} and E(GC) = {(2, 3), (2, 4), (3, 4)} In pictures, we have:

Undirected Graphs: Basic Structure

We begin this section of the lecture by considering two questions related to the basic structure of undirected graphs. Similar considerations can be applied to directed graphs; it is just that the presentation is simpler in the undirected case. Look at the following two graphs. How do they differ? How are they similar? Each of the two graphs contains a triangle and an isolated vertex. Obviously, the two graphs are not the same graph, in that the one on the left has vertex 3 isolated while the one on the right has vertex 1 isolated. We shall develop a concept that describes the basic structural level at which these two graphs are essentially the same graph.

Graph Isomorphism

Two graphs G1 and G2 are said to be isomorphic , denoted by G1  G2, if there exists a one-to-one mapping F from V(G1) onto V(G2) such that (u, v)  E(G1) if and only if (F(u), F(v))  E(G2). Consider the following two graphs, with different vertex labels. These two graphs are isomorphic under the following transformation: F(1) = A, F(2) = B, F(3) = C, and F(4) = D. The edge lists of the two graphs show this. Graph on left: (1, 2), (1, 4), (2, 3), and (3, 4) Graph on right: (A, B), (A, D), (B, C), and (C, D). In a sense, two isomorphic graphs represent the same graph.

More on Isomorphism

The idea of graph isomorphism allows us to focus on the basic structure. If two graphs are non–isomorphic , they have basically different structures. Here are three non–isomorphic graphs on three vertices. For any value of N, there are only a finite number of non–isomorphic graphs on N vertices. We can view these as a finite set. Define  (N) as the set of non–isomorphic graphs on N vertices. Define  (N, M) as the set of non–isomorphic graphs on N vertices and M edges. For smaller values of N (N  4) we may easily display the entire sets (N).

The Set  (4)

Standard Undirected Graphs: PN

Certain graph structures appear with sufficient regularity to be given names. The Path The path on N vertices is a connected graph with (N – 1) edges in the form of a path. It has (N – 2) vertices of degree 2 and two vertices of degree 1. The path on N vertices is denoted by PN. Here are depictions of the graphs P 2 , P 3 , and P 4.