You are on page 1of 23

# 1

Graph theory?
Has nothing to do with graph or graphics An area of math dealing with entities (nodes) and the connections (links) between the nodes

## A graph is an abstract mathematical structure defined from two sets:

V={n1, n2,nm} of nodes E={e1,e2,em} of edges

e1
n1

n2 e4

e2

n3

e3

n4

n5

e5
n7 n6

The degree
Refers to the number of edges that have a node as an endpoint , denoted by deg(n) Indicates the extent of integration testing that is appropriate for the object E.g. deg(n1) =2

Alternative to visual presentation of graph The incidence matrix of G=(V,E) with m nodes and n edges is an mn matrix We have 1 in row i, column J
if node i is an endpoint of edge j Row sum represents degree of nodes Column sum represents the endpoints of an edge

n1 n2 n3 n4 n5 n6 n7

e1 1 1 0 0 0 0 0

e2 1 0 0 1 0 0 0

e3 0 0 1 1 0 0 0

e4 0 1 0 0 1 0 0

e5 0 0 0 1 0 1 0
7

A useful supplement to the incidence matrix The Adjacency matrix of G=(V,E) with m nodes and n edges is an mm matrix
We have 1 in row i, and col. j if
there is an edge between node i and node j, zero otherwise

Used to identify paths and hence equivalence relation to simplify a graph and hence testing
8

n1 n2 n3 n4 n5 n6 n7

n1 0 1 0 1 0 0 0

n2 1 0 0 0 1 0 0

n3 0 0 0 1 0 0 0

n4 1 0 1 0 0 1 0

n5 0 1 0 0 0 0 0

n6 0 0 0 1 0 0 0

n7 0 0 0 0 0 1 0
9

A path is a sequence of edges such that, for any adjacent pair of edges ei, ej in the sequence, the edges share a common (node) endpoint Can be described as sequences of edges or nodes

path
Between n1 and n5 Between n6 and n5 .

Nodes sequence
n1,n2,n5 n6, n4, n1, n2, n5

Edge sequences
e1,e4 e5,e2,e1,e4

10

Nodes ni and nj are connected if they are in the same path Connectedness is an equivalence relation can be checked easily
Reflexive (every node is in path of 0 length with itself) Symmetric n1, and n2 in same path, then n2 and n1 is also in the same path transitive

11

Connectedness defines a partition (or component) on the node set of a graph Components of a graph is maximal set of connected nodes E.g. Components
Condensation graph Used as a Simplification mechanism Creating a graph by replacing a set of connected nodes (or components) by a condensing node The implication for testing is that component are stand alone elements and hence can be tested separately
S1={n1,n2,n3,n4,n5,n6} and S2={n7}

12

## No edges can be present in a condensation graph of an ordinary graph. Two reasons:

Edges have individual nodes as endpoints, not sets of nodes A possible edge would mean that nodes from two different components are connected, thus in a path, thus in the same component.

13

A directed graph D = (V,E) consists of a finite set V = {n1,., nm} of nodes, and a set E = {e1, e2, ,ep}, where each edge ek = <ni, nj> is an ordered pair of nodes.

14

n1 e2

e1

n2 e4

e3 n3

n4 e5

n5

n7
n6

15

The in degree of a node in a directed graph is the number of distinct edges that have the node as a terminal node.
The out-degree of a node in a directed graph is the number of distinct edges that have the node as a start point.

16

The AMD of G=(V,E) with m nodes is an mm matrix where a(i,j) is a 1 if there is an edge from node i to node j, otherwise it is 0
Row sum represents outdegrees Column sum represents indegrees

17

n1 n2 n3 n4 n5 n6 n7

n1 0 0 0 0 0 0 0

n2 1 0 0 0 0 0 0

n3 0 0 0 0 0 0 0

n4 1 0 1 0 0 0 0

n5 0 1 0 0 0 0 0

n6 0 0 0 1 0 0 0

n7 0 0 0 0 0 0 0
18

Source node: a node with in-degree zero Sink node: a node with out-degree=0
Transfer node: node with in-degree 0 and out-degree 0

19

## Direction is important therefore

Directed path (a sequence of edges ei and ej, the terminal node of ei is the initial node of ej ) Cycle (directed path that begins and ends at the same node) Directed semi-path (for adjacent pair of ei, the initial (terminal) node of the first edge is the initial (terminal) node of the second edge
E.g., n1 and n3

20

n1 n2 n3 n4 n5 n6 n7

n1 1 0 0 0 0 0 0

n2 1 1 0 0 0 0 0

n3 0 0 1 0 0 0 0

n4 1 0 1 1 0 0 0

n5 1 1 0 0 1 0 0

n6 1 0 1 1 0 1 0

n7 0 0 0 0 0 0 1
21

## Connectedness of directed graph

0-connected (no path between ni, and nj) 1-connected (semi-path between ni, and nj ) 2-connected(a path between ni, and nj ) 3-connected (a path between ni to nj, and a path between nj, and ni)
Strong components

22

n1 e2

e1

n2 e4

e3 n3

n4 e5

e6
n6

n7

n1 and n6 2-c
n3 and n6 3-c

23