CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing...

69
CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis, Winter 2006 Presented by Jiang Wu [email protected]

Transcript of CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing...

Page 1: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

CS447/ECE453/SE465Prof. Alencar University of Waterloo 1

CS447/ECE453/SE465

Software Testing Tutorial

Winter 2008Based on the tutorials by Prof. Kontogiannis, Winter 2006

Presented by Jiang [email protected]

Page 2: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

CS447/ECE453/SE465Prof. Alencar

Outline of the 12 tutorialsOutline of the 12 tutorials

Graphs Graphs Tutorial 1Tutorial 1 Example Problems Example Problems Tutorial 2Tutorial 2 Project Kickoff Project Kickoff Tutorial 3Tutorial 3 Functional TestingFunctional Testing Tutorial 4, 5Tutorial 4, 5 Structural TestingStructural Testing Tutorial 6, 7, 8Tutorial 6, 7, 8 Integration TestingIntegration Testing Tutorial 9, 10Tutorial 9, 10 System testingSystem testing Tutorial 11Tutorial 11 Software reliabilitySoftware reliability Tutorial 12Tutorial 12

Page 3: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 3University of Waterloo

GraphsGraphs Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 4: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 4University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 5: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 5University of Waterloo

Undirected GraphsUndirected Graphs

A A graphgraph G = (V, E) is composed of a finite G = (V, E) is composed of a finite (and non-empty) set V = {n(and non-empty) set V = {n11, n, n22,…,n,…,nmm} of } of

nodes, and a set E = {enodes, and a set E = {e11, e, e22,…,e,…,epp} of } of

edges, where each edge eedges, where each edge ekk = {n = {nii, n, njj} for } for

some nodes nsome nodes nii, n, njj V V Nodes also called verticesNodes also called vertices Edges also called arcsEdges also called arcs Nodes also called endpoints of an arcNodes also called endpoints of an arc

Page 6: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 6University of Waterloo

Undirected GraphsUndirected Graphs

Nodes are usually program statementsNodes are usually program statements Edges for flow of control, define/use Edges for flow of control, define/use

relationships etc.relationships etc.

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

nodes

edge {n3, n4}

V = {n1, n2, n3, n4, n5, n6, n7}

E = {e1, e2, e3, e4, e5, e6, e7} = {(n1, n2), (n2, n3), (n1, n5), (n4, n5), (n2, n4), (n3, n4), (n4, n6)}

Page 7: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 7University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 8: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 8University of Waterloo

Degree of a NodeDegree of a Node

The The degree of a nodedegree of a node in a graph is the in a graph is the number of edges that have that node as number of edges that have that node as an endpoint. We write deg(n) for the an endpoint. We write deg(n) for the degree of node n.degree of node n.

deg(n1) = 2deg(n2) = 3deg(n3) = 2deg(n4) = 4deg(n5) = 2deg(n6) = 1deg(n7) = 0

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Page 9: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 9University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 10: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 10University of Waterloo

Incidence MatricesIncidence Matrices

Alternative representation of graphsAlternative representation of graphs The The incidence matrixincidence matrix of a graph G = (V, E) of a graph G = (V, E)

with m nodes and n edges is an m with m nodes and n edges is an m xx n n matrix, where the element in row i, column matrix, where the element in row i, column j is 1 if and only if node i is an endpoint of j is 1 if and only if node i is an endpoint of edge j, otherwise the element is 0edge j, otherwise the element is 0

Page 11: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 11University of Waterloo

Incidence MatricesIncidence Matrices

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Sum of a row: degree

Sum of a column: 2

Page 12: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 12University of Waterloo

Incidence MatricesIncidence Matrices

The sum of the entries in any column is 2The sum of the entries in any column is 2 It is a form of integrity checkingIt is a form of integrity checking

The row sum is the degree of the nodeThe row sum is the degree of the node When zero, the node is isolated (unreachable When zero, the node is isolated (unreachable

code, objects never used)code, objects never used)

Page 13: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 13University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 14: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 14University of Waterloo

Adjacency MatricesAdjacency Matrices

Useful supplement to the incidence matrixUseful supplement to the incidence matrix The The adjacency matrixadjacency matrix of a graph G=(V, E) of a graph G=(V, E)

with m nodes is an m with m nodes is an m xx m matrix, where m matrix, where the element in row i, column j is a 1 if and the element in row i, column j is a 1 if and only if there is an edge between node i only if there is an edge between node i and node j, otherwise the element is 0and node j, otherwise the element is 0

Symmetric: element (i, j) = element (j, i)Symmetric: element (i, j) = element (j, i) The row sum is the degree of the nodeThe row sum is the degree of the node

Page 15: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 15University of Waterloo

Adjacency MatricesAdjacency Matrices

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Symmetric

Page 16: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 16University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 17: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 17University of Waterloo

PathsPaths

A A pathpath is a sequence of edges such that, is a sequence of edges such that, for any adjacent pair of edges efor any adjacent pair of edges eii, e, ejj in the in the

sequence, the edges share a common sequence, the edges share a common (node) endpoint(node) endpoint

Sequences of nodes or sequences of Sequences of nodes or sequences of edgesedges

Page 18: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 18University of Waterloo

PathsPaths

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Page 19: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 19University of Waterloo

PathsPaths

If we multiply an adjacency matrix with itself the product will show If we multiply an adjacency matrix with itself the product will show the number of all two edge paths of the graph. If we further multiply the number of all two edge paths of the graph. If we further multiply the product with the original adjacency matrix the new product will the product with the original adjacency matrix the new product will show the number of all three edge paths of the graphshow the number of all three edge paths of the graph

=

2

Page 20: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 20University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 21: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 21University of Waterloo

ConnectednessConnectedness

Nodes nNodes nii and n and njj are are connectedconnected if and only if and only if they are in the same pathif they are in the same path

Connectedness is an equivalence relation Connectedness is an equivalence relation on the node set of a graphon the node set of a graph Reflexive: every node is in a path of length 0 Reflexive: every node is in a path of length 0

with itselfwith itself Symmetric: if (nSymmetric: if (n ii, n, nj)j) path, then (n path, then (n jj, n, nii) path) path Transitive: if (nTransitive: if (n ii, n, njj) path and (n) path and (n jj, n, nww) path, ) path,

then (nthen (nii, n, nww) path) path

Page 22: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 22University of Waterloo

ConnectednessConnectedness

Equivalence relations induce a partitionEquivalence relations induce a partition Connectedness defines a partition on the Connectedness defines a partition on the

node set of a graphnode set of a graph A A componentcomponent of a graph is a maximal set of a graph is a maximal set

of connected nodesof connected nodesn1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

{n1, n2, n3, n4, n5, n6}, {n7}

{n1, n2} is not a component

Page 23: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 23University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 24: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 24University of Waterloo

Condensation GraphsCondensation Graphs

Given a graph G = (V, E), its Given a graph G = (V, E), its condensation condensation graphgraph is formed by replacing each is formed by replacing each component by a condensing nodecomponent by a condensing node

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

S1 = {n1, n2, n3, n4, n5, n6}

S2 = {n7}

Page 25: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 25University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 26: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 26University of Waterloo

Cyclomatic NumberCyclomatic Number

The The cyclomatic number of a graphcyclomatic number of a graph G is given by G is given by V(G) = e – n + p, e: number of edges, n: number V(G) = e – n + p, e: number of edges, n: number of nodes, p: number of componentsof nodes, p: number of components

Number of distinct regions in a graphNumber of distinct regions in a graph

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Cyclomatic Number: 7 – 7 + 2 = 2

Page 27: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453

Cyclomatic NumberCyclomatic Number

2 0 0

Page 28: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 28University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 29: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 29University of Waterloo

Directed GraphsDirected Graphs

A A directed graphdirected graph (digraph) D = (V, E) (digraph) D = (V, E) consists of a finite set V = {nconsists of a finite set V = {n11, n, n22,…,n,…,nmm} of } of nodes, and a set E = {enodes, and a set E = {e11, e, e22,…,e,…,epp} of } of edges, where each edge eedges, where each edge ekk = <n = <nii, n, njj> is an > is an ordered pair of nodes nordered pair of nodes nii, n, njj V V nnii: initial (start) node, n: initial (start) node, n jj terminal (finish) node terminal (finish) node

Software concepts represented with Software concepts represented with directed graphs: sequential behavior, time-directed graphs: sequential behavior, time-ordered events, messages etc.ordered events, messages etc.

Page 30: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 30University of Waterloo

Directed GraphsDirected Graphs

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

V = {n1, n2, n3, n4, n5, n6, n7}

E = {e1, e2, e3, e4, e5, e6, e7} = {<n1, n2>, <n2, n3>, <n5, n2>, <n4, n5>, <n2, n4>, <n3, n4>, <n4, n6>}

Page 31: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 31University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 32: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 32University of Waterloo

Indegrees and OutdegreesIndegrees and Outdegrees

The The indegree of a nodeindegree of a node in a directed graph in a directed graph is the number of distinct edges that have is the number of distinct edges that have the node as a terminal node (indeg(n))the node as a terminal node (indeg(n))

The The outdegree of a nodeoutdegree of a node in a directed in a directed graph is the number of distinct edges that graph is the number of distinct edges that have the node as an start point (outdeg(n))have the node as an start point (outdeg(n))

deg(n) = indeg(n) + outdeg(n)deg(n) = indeg(n) + outdeg(n)

Page 33: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 33University of Waterloo

Indegrees and OutdegreesIndegrees and Outdegrees

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

indeg(n1) = 0indeg(n2) = 2indeg(n3) = 1indeg(n4) = 2indeg(n5) = 1indeg(n6) = 1indeg(n7) = 0

outdeg(n1) = 1outdeg(n2) = 2outdeg(n3) = 1outdeg(n4) = 2outdeg(n5) = 1outdeg(n6) = 0outdeg(n7) = 0

Page 34: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 34University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 35: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 35University of Waterloo

Types of NodesTypes of Nodes

Source Node: indegree = 0Source Node: indegree = 0 Sink Node: outdegree = 0Sink Node: outdegree = 0 Transfer Node: indegree Transfer Node: indegree ≠ 0 && ≠ 0 &&

outdegree ≠ 0outdegree ≠ 0 Isolated Node: indegree = 0 && Isolated Node: indegree = 0 &&

outdegree = 0outdegree = 0 External Entities: Source and Sink NodesExternal Entities: Source and Sink Nodes

Page 36: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 36University of Waterloo

Types of NodesTypes of Nodes

Source Nodes: n1

Sink Nodes: n6

Transfer Nodes: n2, n3, n4, n5

Isolated Nodes: n7

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Page 37: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 37University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 38: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 38University of Waterloo

Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph

The The adjacency matrixadjacency matrix of a directed graph of a directed graph D = (V, E) with m nodes is a m D = (V, E) with m nodes is a m xx m matrix m matrix A=(a(i, j)), where a(i, j) is a 1 if and only if A=(a(i, j)), where a(i, j) is a 1 if and only if there is an edge from node i and node j, there is an edge from node i and node j, otherwise the element is 0otherwise the element is 0

Not necessarily symmetricNot necessarily symmetric Row sum = outdegree of nodeRow sum = outdegree of node Column sum = indegree of nodeColumn sum = indegree of node

Page 39: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 39University of Waterloo

Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Page 40: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 40University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 41: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 41University of Waterloo

Paths and Semi – PathsPaths and Semi – Paths

A A (directed) path(directed) path is a sequence of edges such is a sequence of edges such that, for any adjacent pair of edges ethat, for any adjacent pair of edges e ii, e, ejj, in the , in the sequence, the terminal node of the first edge is sequence, the terminal node of the first edge is the initial node of the second edgethe initial node of the second edge

A A cyclecycle is a directed path that begins and ends is a directed path that begins and ends at the same nodeat the same node

A A (directed) semi – path(directed) semi – path is a sequence of edges is a sequence of edges such that, for at least one adjacent pair of edges such that, for at least one adjacent pair of edges eeii, e, ejj in the sequence, the initial node of the first in the sequence, the initial node of the first edge is the initial node of the second edge or the edge is the initial node of the second edge or the terminal node of the first edge is the terminal terminal node of the first edge is the terminal node of the second edgenode of the second edge

Page 42: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 42University of Waterloo

Paths and Semi – PathsPaths and Semi – Paths

Directed paths also called chainsDirected paths also called chains

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Path: n1 → n2 → n3

Cycle: n2 → n4 → n5 → n2

Semi – Path: e1 , e3

Semi – Path: e2 , e5

Page 43: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 43University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 44: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 44University of Waterloo

Reachability MatrixReachability Matrix

The The reachability matrix of a directed graphreachability matrix of a directed graph D = (V, E) with m nodes is a m D = (V, E) with m nodes is a m xx m matrix m matrix R = (r(i, j)), where r(i, j) is a 1 if and only if R = (r(i, j)), where r(i, j) is a 1 if and only if there is a path from node i and node j, there is a path from node i and node j, otherwise the element is 0otherwise the element is 0

Page 45: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 45University of Waterloo

Reachability MatrixReachability Matrix

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

Page 46: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 46University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 47: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 47University of Waterloo

N – ConnectednessN – Connectedness

Two nodes nTwo nodes nii and n and njj in a directed graph in a directed graph are:are: 0-connected0-connected iff there is no path between n iff there is no path between n ii

and nand njj

1-connected1-connected iff there is a semi-path but NO iff there is a semi-path but NO path between npath between nii and n and njj

2-connected2-connected iff there is a path between n iff there is a path between n ii and and nnjj

3-connected3-connected iff there is a path from n iff there is a path from n jj to n to nii and and a path from na path from nii to n to njj

Page 48: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 48University of Waterloo

N – ConnectednessN – Connectedness

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

n1 and n7 are 0-connected

n1 and n8 are 1-connected

n2 and n6 are 2-connected

n3 and n5 are 3-connected

n8

Page 49: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 49University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 50: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 50University of Waterloo

Strong ComponentsStrong Components

A A strong component of a directed graphstrong component of a directed graph is is a maximal set of 3-connected nodesa maximal set of 3-connected nodes

Practically loops and isolated nodes are Practically loops and isolated nodes are removed and replaced by strong removed and replaced by strong components (directed acyclic graphs)components (directed acyclic graphs)

Page 51: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 51University of Waterloo

Condensation GraphsCondensation Graphs

S1 = {n2, n3, n4, n5}

S2 = {n7}

n1

n5

n2 n3

n4

n6 n7

e1 e2

e3

e4

e5e6

e7

n1 S1

n6 S2

e1

e7

Page 52: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 52University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 53: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 53University of Waterloo

Program GraphsProgram Graphs

A A program graphprogram graph is a directed graph in which: is a directed graph in which: Traditional Definition: Nodes are program statements, Traditional Definition: Nodes are program statements,

and edges represent flow of control (there is an edge and edges represent flow of control (there is an edge from node i to node j iff the statement corresponding from node i to node j iff the statement corresponding to node j can be executed immediately after the to node j can be executed immediately after the statement corresponding to node i)statement corresponding to node i)

Improved Definition: Nodes are either entire Improved Definition: Nodes are either entire statements or fragments of a statement, and edges statements or fragments of a statement, and edges represent flow of control (there is an edge from node i represent flow of control (there is an edge from node i to node j iff the statement or statement fragment to node j iff the statement or statement fragment corresponding to node j can be executed immediately corresponding to node j can be executed immediately after the statement or statement fragment after the statement or statement fragment corresponding to node i)corresponding to node i)

Primarily used at the unit testing levelPrimarily used at the unit testing level

Page 54: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 54University of Waterloo

Program GraphsProgram Graphs

Page 55: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 55University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 56: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 56University of Waterloo

Finite State MachinesFinite State Machines

A A Finite State MachineFinite State Machine (FSM) is a directed (FSM) is a directed graph (S, T, Ev, Act), in whichgraph (S, T, Ev, Act), in which S: set of nodes (states)S: set of nodes (states) T: set of edges (transitions)T: set of edges (transitions) Ev, Act: sets of events and actions associated Ev, Act: sets of events and actions associated

with the transitions in Twith the transitions in T Primarily used to describe system level Primarily used to describe system level

behaviorbehavior

Page 57: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 57University of Waterloo

Finite State MachinesFinite State Machines

Example: LampExample: Lamp

Node

Transition

Action

Event

Page 58: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 58University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 59: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 59University of Waterloo

Petri NetsPetri Nets

A A Petri netPetri net is a bipartite directed graph is a bipartite directed graph (P, T, In, Out), in which(P, T, In, Out), in which P (places), T (transitions): disjoint sets of P (places), T (transitions): disjoint sets of

nodesnodes In, Out: sets of edges, where In P x T, and In, Out: sets of edges, where In P x T, and

Out T x P Out T x P Primarily used to describe system level Primarily used to describe system level

behaviorbehavior

Page 60: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 60University of Waterloo

Petri NetsPetri Nets

P = {p1, p2, p3, p4}

T = {t1, t2, t3}

In = {<p1, t1>, <p1, t2>, <p2, t2>, <p4, t3>}

Out = {<t1, p3>, <t2, p4>, <t3, p3>}

Page 61: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 61University of Waterloo

Petri NetsPetri Nets

A A marked Petri netmarked Petri net is a 5-tuple (P, T, In, is a 5-tuple (P, T, In, Out, M) in which (P, T, In, Out) is a Petri Out, M) in which (P, T, In, Out) is a Petri net and M (marking set) is a set of net and M (marking set) is a set of mappings of places to positive integersmappings of places to positive integers

The number associated with a place refers The number associated with a place refers to the number of tokens that are said to be to the number of tokens that are said to be “in” the place“in” the place e.g. number of times a place has been usede.g. number of times a place has been used

Page 62: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 62University of Waterloo

Petri NetsPetri Nets

P = {p1, p2, p3, p4}

T = {t1, t2, t3}

In = {<p1, t1>, <p1, t2>, <p2, t2>, <p4, t3>}

Out = {<t1, p3>, <t2, p4>, <t3, p3>}

M = {2, 0, 1, 3}

Page 63: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 63University of Waterloo

Petri NetsPetri Nets

A transition in a Petri net is A transition in a Petri net is enabledenabled if if there is at least one token in each of its there is at least one token in each of its input placesinput places

Enabled Transitions: t1, t3

Page 64: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 64University of Waterloo

Petri NetsPetri Nets

When an enabled Petri net transition When an enabled Petri net transition firesfires, , one token is removed from each of its one token is removed from each of its input places, and one token is added to input places, and one token is added to each of its output placeseach of its output places

Page 65: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 65University of Waterloo

Petri NetsPetri Nets

→t3 fired

M = {<2, 0, 1, 3>, <2, 0, 2, 2>}

Page 66: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 66University of Waterloo

Petri NetsPetri Nets

Conservative Petri nets: total number of Conservative Petri nets: total number of tokens never changestokens never changes

Petri net conflictsPetri net conflicts

Transitions t1 and t2 are in conflict with respect to place p1

Page 67: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453

Petri Net ExamplePetri Net Example

http://www.informatik.uni-hamburg.de/TGI/http://www.informatik.uni-hamburg.de/TGI/PetriNets/introductions/aalst/elevator1.swfPetriNets/introductions/aalst/elevator1.swf

Page 68: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 68University of Waterloo

AgendaAgenda Undirected GraphsUndirected Graphs

Degree of a NodeDegree of a Node Incidence MatricesIncidence Matrices Adjacency MatricesAdjacency Matrices PathsPaths ConnectednessConnectedness Condensation GraphsCondensation Graphs Cyclomatic NumberCyclomatic Number

Directed GraphsDirected Graphs Indegrees and OutdegreesIndegrees and Outdegrees Types of NodesTypes of Nodes Adjacency Matrix of a Directed GraphAdjacency Matrix of a Directed Graph Paths and Semi – PathsPaths and Semi – Paths Reachability MatrixReachability Matrix N – ConnectednessN – Connectedness Strong ComponentsStrong Components

Graphs for TestingGraphs for Testing Program GraphsProgram Graphs Finite State MachinesFinite State Machines Petri NetsPetri Nets

Page 69: CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

ECE 453 69University of Waterloo

ReferencesReferences

Software Testing A Craftsman's Approach Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC 2nd edition, Paul C. Jorgensen, CRC Press Press