Modeling and Simulation NETW 707

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Graph & BFS.
Connected Components, Directed Graphs, Topological Sort COMP171.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Fall 2014 Doug James Lecture 17: Graphs.
Parallel Programming – Graph Algorithms David Monismith CS599 Notes are primarily based upon Introduction to Parallel Programming, Second Edition by Grama,
Social Media Mining Graph Essentials.
Graph Theory Chapter 6 from Johnsonbaugh Article(6.1, 6.2)
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
CS 3343: Analysis of Algorithms Lecture 21: Introduction to Graphs.
Graph Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 2 Graph Algorithms.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm.
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 5 Graph Algorithms.
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
Introduction to Graph Theory
Data Structures & Algorithms Graphs
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Overview of Graph Theory. Some applications of Graph Theory Models for communications and electrical networks Models for computer architectures Network.
Graphs Slide credits:  K. Wayne, Princeton U.  C. E. Leiserson and E. Demaine, MIT  K. Birman, Cornell U.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
CSC2100B Tutorial 10 Graph Jianye Hao.
CSCI2100 Data Structures Tutorial 12
Graphs Upon completion you will be able to:
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graph Revisited Fei Chen CSCI2100B Data Structures Tutorial 12 1.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
Graphs Lecture 19 CS2110 – Spring 2013.
Graphs Representation, BFS, DFS
Lecture 11 Graph Algorithms
Shortest Paths and Minimum Spanning Trees
GRAPHS Lecture 16 CS2110 Fall 2017.
Graph theory Definitions Trees, cycles, directed graphs.
CS 3343: Analysis of Algorithms
Topological Sort (topological order)
Short paths and spanning trees
Graph Algorithm.
Graph & BFS.
Graphs Lecture 18 CS2110 – Fall 2009.
Chapter 22: Elementary Graph Algorithms I
Chapter 9: Graphs Basic Concepts
Chapter 11 Graphs.
Shortest Path Algorithms
Shortest Paths and Minimum Spanning Trees
Chapter 15 Graphs © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
CSCI2100 Data Structures Tutorial
Text Book: Introduction to algorithms By C L R S
Graphs G = (V, E) V are the vertices; E are the edges.
CSE 417: Algorithms and Computational Complexity
GRAPHS Lecture 17 CS2110 Spring 2018.
Chapter 10 Graphs and Trees
Algorithm Course Dr. Aref Rashad
Lecture 10 Graph Algorithms
Chapter 9: Graphs Basic Concepts
Graphs G = (V,E) V is the vertex set.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Modeling and Simulation NETW 707 Lecture 9 Network & Topology Modeling Course Instructor: Dr.-Ing. Maggie Mashaly maggie.ezzat@guc.edu.eg C3.220

Examples of relevant Networks Sensor Networks The Internet Social Networks

Graph Theory Begun in 1735 Bridges of Königsberg (today’s Kaliningrad): walk all 7 bridges without crossing a bridge twice B1 B2 B3 B4 B5 B6 B7 LC LB LA LD 3 Edges 5 Edges B A C D 1 2 3 4 6 7 5 Solved by: Parity of Nodes Replace each land mass with an abstract vertex or node Replace each bridge with an edge

Network Modeling using Graph Theory Networks can be represented by graphs Router/Switch nodes modeled as vertices Communication links modeled as edges Vertices Edges

Basic Concepts/Definitions Graph – A Graph is defined as a set of: V = Nodes (vertices) E = Edges (links, arcs) between pairs of nodes Denoted by G = (V, E). Graph Size Parameters: Order of G : number of vertices, n = |V| Size of G : number of edges, m = |E| The running time of algorithms are usually measured in terms of the order and size of a graph

Directed Graph An edge e  E of a directed graph is represented as an ordered pair (u,v), where u, v  V u is the initial vertex v is the terminal vertex. u ≠ v 2 3 1 4 V = {1, 2, 3, 4}, |V | = 4 E = {(1,2), (2,3), (2,4), (4,1), (4,2)}, |E | = 5

Undirected Graph An edge e  E of an undirected graph is represented as an unordered pair (u,v) = (v,u), where u, v  V, u ≠ v 2 3 1 4 V = {1, 2, 3, 4}, |V | = 4 E = {(1,2), (2,3), (2,4), (4,1)}, |E |=4

Degree of a Vertex In an undirected graph Degree of a vertex is the number of edges incident on it. In a directed graph, the out degree of a vertex is the number of edges leaving it and the in degree is the number of edges entering it. 2 4 3 1 2 4 3 1 The degree of vertex 2 is 3 The in degree of vertex 2 is 2 and the out degree of vertex 3 is 0

Adjacent/Neighbor Nodes If edge e={u,v} ∈ E, u and v are adjacent or neighbors 2 3 1 4 (1,2), (2,3), (2,4), (4,1) are all Adjacent/Neighbor Nodes

Weighted Graph A weighted graph is a graph for which each edge has an associated weight 2 4 3 1 5 2 4 3 1 8 6 9

Walks and Paths 3 V2 V3 1 2 3 V1 1 V6 4 4 V4 V5 1 A walk is an sequence of nodes (v1, v2,..., vL) such that {(v1, v2), (v2, v3),..., (vL-1, vL)} E, e.g. (V2, V3,V6, V5,V3) A simple path is a walk with no repeated nodes, e.g. (V1, V4,V5, V2,V3) A cycle is a walk (v1, v2,..., vL) where v1=vL with no other nodes repeated and L>3, e.g. (V1, V2,V5, V4,V1) A graph is called cyclic if it contains a cycle; otherwise it is called acyclic

Complete Graphs A complete graph is an undirected/directed graph in which every pair of vertices is adjacent. A A B B C C D 4 nodes and (4 × 3)/2 edges V nodes andV × (V-1)/2 edges 3 nodes and 3 × 2 edges V nodes and V × (V-1) edges

Connected Graph An undirected graph is connected if you can get from any node to any other by following a sequence of edges OR any two nodes are connected by a path A directed graph is strongly connected if there is a directed path from any node to any other node A graph is sparse if | E |  | V | A graph is dense if | E |  | V |2 A D E F B C A B C D

Bipartite Graph A bipartite graph is an undirected graph G = (V,E ) in which V can be partitioned into 2 sets V1 and V2 such that (u,v)  E implies u  V1 and v  V2 or vice versa V1 V2 v11 v21 v12 v22 v13 v23 v14

Trees An undirected graph is a tree if it is connected and does not contain a cycle. For an undirected tree Graph G, the following statements are equivalent: Any two vertices in G are connected by unique simple path G is connected, but if any edge is removed from E, the resulting graph is disconnected G is connected, and | E | = | V | -1 G is acyclic, and | E | = | V | -1 G is acyclic, but if any edge is added to E, the resulting graph contains a cycle A B C D E F

Spanning Tree G A tree (T ) is said to span G = (V,E ) if T = (V,E’ ) and E’ E There are usually several possible spanning trees V2 V3 V6 V1 V4 V5 Two example Spanning Trees of G V2 V5 V4 V3 V2 V1 V6 V3 V6 V1 V4 V5

Minimum Spanning Tree A Minimum Spanning Tree (MST) is a spanning tree of G whose sum of edge weights is minimized 1 3 8 2 6 7 4 5 23 10 21 14 16 18 9 11 24 1 3 8 2 6 7 4 5 9 11 G = (V, E ) T = (V, F ) w (T ) = 50 Cayley's Theorem (1889) There are nn-2 spanning trees of a complete graph Gn n = |V |, m = |E | Can't solve MST by exhaustive search (because of nn-2)

MST Computation Prim’s Algorithm: Select an arbitrary node as the initial tree (T) Augment T in an iterative fashion by adding the outgoing edge (u,v), (i.e., u  T and v  G-T ) with minimum cost (i.e., weight) The algorithm stops after |V| - 1 iterations Computational complexity = O (|V|2)

Prim’s Algorithm (Example) V2 3 V3 V1 V2 V3 1 Algorithm starts 2 3 V6 3 V2 V1 1 1 1 4 1 4 V1 V1 V4 V5 After the 1st iteration After the 2nd iteration V3 V3 V2 3 V2 3 V2 3 V3 1 1 1 2 3 1 1 1 V1 V1 V1 V6 1 1 V4 V4 V5 V5 V5 After the 3rd iteration After the 4th iteration After the 5th iteration

MST Computation Kruskal’s Algorithm: Select the edge e  E of minimum weight → E’ = {e} Continue to add the edge e  E – E’ of minimum weight that when added to E’, does not form a cycle Computational complexity = O(|E|×log|E|)

Kruskal’s Algorithm (Example) V2 3 V3 V2 V3 1 V2 2 1 1 3 1 V6 After the 1st iteration V1 V1 V1 1 4 1 4 V4 V2 V3 V4 V5 1 V5 V1 1 1 After the 3rd iteration After the 2nd iteration V5 V2 V3 V2 3 V3 1 1 2 2 1 1 V1 V1 V6 V6 1 1 V4 V5 V4 V5 After the 4th iteration After the 5th iteration

Shortest Path Spanning Tree T, is a shortest path spanning tree Rooted at a particular node |V |-1 minimum weight paths from that node to each of the other network nodes is contained in T 2 4 3 1 6 5 Graph Minimum Spanning Tree Shortest Path Spanning Tree rooted at vertex 1

Shortest Path Algorithms Dijkstra Bellman-Ford Algorithm Floyd-Warshall Algorithm

Graph Representation: Adjacency Matrix is an n×n matrix with Auv = 1 if (u, v) is an edge Symmetric matrix for undirected graphs (not for directed graphs) Space: proportional to n2. Not efficient for sparse graphs Algorithms might have longer running time if this representation used Checking if (u, v) is an edge consumes O(1) time. Identifying all edges consumes O(n2) time.

Graph Representation: Adjacency List is a Node-indexed array of lists Two representations of each edge Space proportional to m + n Checking if (u, v) is an edge consumes O(deg(u)) time Identifying all edges takes O(m+n) time Requires O(m+n) space. Good for dealing with sparse graphs

Graph Representation Adjacency Matrix Adjacency List 1 2 3 4 5 6 7 8 1 Adjacency Matrix 1 2 3 4 5 7 8 6 Adjacency List

Running Times of Algorithms Analyzing an Algorithm over a Graph: Predicting resources (computational time and memory space ) required Running Time of an algorithm: the number of steps executed as a function of its input (for G, input is n=|V| and m=|E|) Order of Growth: consider only the leading term of the running time, since lower-order terms are relatively insignificant for large n E.g., O(an2 + bn + c) is O(n2) An algorithm is efficient if its running time is low order polynomial (quadratic)

References NETW 707 Lectures slides by A. Prof. Tallal El-Shabrawy, 2016 & 2017 “Simulation Modeling and Analysis” by Averill M. Law, 5th Edition, 2015