COMP 6710 Course NotesSlide 7-0 Auburn University Computer Science and Software Engineering Course Notes Set 7: Review of Graphs Computer Science and Software.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Discrete Mathematics University of Jazeera College of Information Technology & Design Khulood Ghazal Connectivity Lecture _13.
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
Chapter 6 Path Testing Software Testing
Introduction to Graph “theory”
1 Ivan Marsic Rutgers University LECTURE 15: Software Complexity Metrics.
Graph Theory.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Structural Testing Structural testing is based on selecting paths through a code segment for execution. First, we assume that each code segment has a single.
Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects two different vertices. Edges are.
Testing for Connectedness & Cycles Connectedness of an Undirected Graph Implementation of Connectedness detection Algorithm. Implementation of Strong Connectedness.
Testing for Connectedness and Cycles Connectedness of an Undirected Graph Implementation of Connectedness detection Algorithm. Implementation of Strong.
CS2420: Lecture 36 Vladimir Kulyukin Computer Science Department Utah State University.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The methodology.
A Complexity Measure THOMAS J. McCABE Presented by Sarochapol Rattanasopinswat.
GRAPHS Education is what remains after one has forgotten what one has learned in school. Albert Einstein Albert Einstein Smitha N Pai.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Lecture 9 Instructor Paulo Alencar.
Graph. Data Structures Linear data structures: –Array, linked list, stack, queue Non linear data structures: –Tree, binary tree, graph and digraph.
Been-Chian Chien, Wei-Pang Yang, and Wen-Yang Lin 6-1 Chapter 6 Graphs Introduction to Data Structure CHAPTER 6 GRAPHS 6.1 The Graph Abstract Data Type.
Directed graphs Definition. A directed graph (or digraph) is a pair (V, E), where V is a finite non-empty set of vertices, and E is a set of ordered pairs.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Reference Paulo Alencar, University of Waterloo Frank Tsui, Southern Polytechnic State University.
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
Introduction to Graph “theory” Why do we care about graph theory in testing and quality analysis? –The “flow” (both control and data) of a design, within.
Presented by: Ritesh Jain Date: 16-Jun-05 Software Quality Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Data Structures & Algorithms Graphs
BASIS PATH TESTING.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
Chapter 8 Path Testing. Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Overview Structural Testing Introduction – General Concepts
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Graphs 황승원 Fall 2010 CSE, POSTECH. 2 2 Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Agent program is the one part(class)of Othello program. How many test cases do you have to test? Reversi [Othello]
Graphs Upon completion you will be able to:
Copyright © Curt Hill Graphs Definitions and Implementations.
Chapter 9: Graphs.
Graphs and Paths : Chapter 15 Saurav Karmakar
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Lecture #13. Topics 1.The Graph Abstract Data Type. 2.Graph Representations. 3.Elementary Graph Operations.
White-Box Testing Statement coverage Branch coverage Path coverage
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Subject Four Graphs Data Structures. What is a graph? A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes.
BASIS PATH TESTING.
Data Structures 13th Week
Software Engineering (CSI 321)
Structural testing, Path Testing
White Box Testing.
Chapter 9 Path Testing–Part 1
Constructing and Using
Graphs Chapter 13.
Graph Operations And Representation
Graphs Chapter 7 Visit for more Learning Resources.
Graphs G = (V, E) V are the vertices; E are the edges.
Graphs G = (V,E) V is the vertex set.
Unit III – Chapter 3 Path Testing.
Presentation transcript:

COMP 6710 Course NotesSlide 7-0 Auburn University Computer Science and Software Engineering Course Notes Set 7: Review of Graphs Computer Science and Software Engineering Auburn University

COMP 6710 Course NotesSlide 7-1 Auburn University Computer Science and Software Engineering Graphs Graph theory is a branch of topology, so is a mathematically rigorous subject. For our purposes, however, we will only need to understand graphs at the level presented in an undergraduate data structures and algorithms course. Although undirected graphs are the more general concept, we will only discuss directed graphs.

COMP 6710 Course NotesSlide 7-2 Auburn University Computer Science and Software Engineering Directed Graphs A directed graph (or digraph) G = (V, E) consists of a finite set V = {n 1, n 2, …, n m } of nodes and a finite set E = {e 1, e 2, …, e p } of edges, where each edge e k = {n i, n j } is an ordered pair (start-node, terminal-node) of nodes from V. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 V = {n1, n2, n3, n4, n5, n6, n7} E = {e1, e2, e3, e4, e5, e6} = {(n1, n2), (n1, n4), (n3, n4), (n2, n5), (n4, n6), (n6, n3)}

COMP 6710 Course NotesSlide 7-3 Auburn University Computer Science and Software Engineering Nodes and Degrees Indegree(node) = number of distinct edges that have the node as a terminal node. Outdegree(node) = number of distinct edges that have the node as a start node. Source node = a node with indegree 0. Sink node = a node with outdegree 0. Transfer node = a node with indegree != 0 and outdegree != 0. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 Indegree(n1) = 0 Indegree(n2) = 1 Indegree(n4) = 2 Indegree(n7) = 0 Outdegree(n1) = 2 Outdegree(n2) = 1 Outdegree(n4) = 1 Outdegree(n7) = 0

COMP 6710 Course NotesSlide 7-4 Auburn University Computer Science and Software Engineering Paths and Semi-Paths Directed Path = a sequence of edges such that, for any adjacent pair of edges e i, e j in the sequence, the terminal node of the first edge is the start node of the second edge. Directed Semi-path = a sequence of edges such that, for at least one adjacent pair of edges ei, ej in the sequence, the initial node of the first edge is the initial node of the second edge, or the terminal node of the first edge is the terminal node of the second edge. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 There is a path from n1 to n6. There is a semi-path between n1 and n3. There is a semi-path between n2 and n4. There is a semi-path between n5 and n6.

COMP 6710 Course NotesSlide 7-5 Auburn University Computer Science and Software Engineering Connectedness Two nodes n i and n j in a directed graph are: 0-connected iff there is no path or semi-path between n i and n j. 1-connected iff there is a semi-path but no path between n i and n j. 2-connected iff there is a path between n i and n j. 3-connected iff there is a path from n i to n j and a path from n j to n i. A graph is connected iff all pairs of nodes are either 1-connected or 2- connected. A graph is strongly connected iff all pairs of nodes are 3- connected. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 n1 and n7 are 0-connected. n2 and n6 are 1-connected. n1 and n6 are 2-connected. n3 and n6 are 3-connected. The graph is not connected. The graph is not strongly connected.

COMP 6710 Course NotesSlide 7-6 Auburn University Computer Science and Software Engineering Connectedness n1n2 n4n5 n7n6 n3 e1 e3 e4 e5 e6 e2 e7 e8 e9 n1n2 n4n5 n7n6 n3 e1 e3 e4 e5 e6 e2 e7 e8 Connected, but not strongly connected. Strongly connected.

COMP 6710 Course NotesSlide 7-7 Auburn University Computer Science and Software Engineering Strong Components A strong component of a directed graph is a maximal set of 3-connected nodes; that is, a maximal set of strongly connected nodes. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 {n3, n4, n6} is a strong component. {n7} is a strong component.

COMP 6710 Course NotesSlide 7-8 Auburn University Computer Science and Software Engineering Cyclomatic Number The cyclomatic number of a strongly connected directed graph G = (V, E) is given by v(G) = |E| - |V| + p, where p is the number of strong components in the graph. v(G) is also equal to the number of bounded areas defined by the graph. v(G) = 9 – = 3 n1n2 n4n5 n7n6 n3 e1 e3 e4 e5 e6 e2 e7 e8 e9

COMP 6710 Course NotesSlide 7-9 Auburn University Computer Science and Software Engineering Program Graphs Given a program written in an imperative programming language, its program graph is a directed graph in which nodes are either entire statements or fragments of a statement, and edges represent flow of control. At the module level, program graphs should be connected. Loops will define strongly connected components.

COMP 6710 Course NotesSlide 7-10 Auburn University Computer Science and Software Engineering Graphs for Control Constructs m1 m2 m3 Sequence { m1(); m2(); m3(); } c m1 m2 if-then if (c) { m1(); } m2(); c m1m2 m3 if-then-else if (c) { m1(); } else { m2(); } m3(); c m1 m2m3 mn mm … Switch/multi-way decision

COMP 6710 Course NotesSlide 7-11 Auburn University Computer Science and Software Engineering Graphs for Control Constructs c m1 m2 Pre-test Loop while (c) { m1(); } m2(); m1 c m2 Post-test Loop do { m1(); } while (c); m2();

COMP 6710 Course NotesSlide 7-12 Auburn University Computer Science and Software Engineering Program Graph Example s1(); if (c1) { s2(); } else { s3(); } s4(); while (c2) { s5(); } s6(); s1 c1 s2s3 s4 c2 s5 s6

COMP 6710 Course NotesSlide 7-13 Auburn University Computer Science and Software Engineering Program Graph Example ÏÏÏ ¬¹¹¹¹¹¹¹¹¹ 2 ÏÏÞßà public static String triangle (int a, int b, int c) { ÏÏϪ˹¹¹¹¹¹¹¹ 3 ÏÏÏϨ¹íÏ String result; 4 ÏÏÏϨ¹íÏ boolean isATriangle; 5 ÏÏÏϨ¹³´ if ( ( a < b + c ) && ( b < a + c ) && ( c < a + b ) ) { 6 ÏÏÏϧÏ6¾¹¹Ï isATriangle = true; 7 ÏÏÏϧÏ6Ï } 8 ÏÏÏϧÏö´ else { 9 ÏÏÏϧϸ¾¹¹Ï isATriangle = false; 10 ÏÏÏϧÏÈÏ } 11 ÏÏÏϨ¹³´ if ( isATriangle ) { 12 ÏÏÏϧÏ6¾¹³´ if ( ( a == b ) && ( b == c ) ) { 13 ÏÏÏϧÏ6ÏÏ6¾¹¹Ï result = "Triangle is equilateral."; 14 ÏÏÏϧÏ6ÏÏ6Ï } 15 ÏÏÏϧÏ6ÏÏ÷´ else if ( ( a != b ) && ( a != c ) && ( b != c ) ) { 16 ÏÏÏϧÏ6ÏÏ6¾¹¹Ï result = "Triangle is scalene."; 17 ÏÏÏϧÏ6ÏÏ6Ï } 18 ÏÏÏϧÏ6ÏÏö´ else { 19 ÏÏÏϧÏ6Ïϸ¾¹¹Ï result = "Triangle is isosceles."; 20 ÏÏÏϧÏ6ÏÏÈÏ } 21 ÏÏÏϧÏ6Ï } 22 ÏÏÏϧÏö´ else { 23 ÏÏÏϧϸ¾¹¹Ï result = "Not a triangle."; 24 ÏÏÏϧÏÈÏ } 25 ÏÏ¹Ĺ¹Ï return result; 26 ÏÏÏÏ© }

COMP 6710 Course NotesSlide 7-14 Auburn University Computer Science and Software Engineering Condensation Graph Given a graph G = (V, E), its condensation graph is formed by replacing some components with a condensing node. n1n2 n4n5 n7n6 n3 e1 e2 e3 e4 e5 e6 Condensation Graph: n1n2 n5 C2 e1 e2 e4 C1 Results from condensing strong components.

COMP 6710 Course NotesSlide 7-15 Auburn University Computer Science and Software Engineering Condensation Graph C1 6 9 C2 23 C3C Condense compound conditions