170 likes | 182 Views
This example details relevant networks, such as sensor networks and the internet, with a focus on graph theory, modeling networks using graphs, and fundamental concepts like vertices, edges, directed and undirected graphs, adjacency, walks, paths, and more.
E N D
Example of Relevant Networks Sensor Networks The Internet Social Networks
Graph Theory • Begun in 1735 • Bridges of Konigsberg (today’s Kaliningrad): walk all 7 bridges without crossing a bridge twice A 6 B6 2 1 LA 5 D C B1 B2 LC 4 3 B3 LD B4 B5 7 B Solved by: parity of nodes B7 LB 3 Edges 5 Edges 3 Edges 3 Edges
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 • uis the initial vertex • vis 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 Degree of a vertex in an undirected graph is the number of edges incident on it. In a directed graph, the out degreeof a vertex is the number of edges leaving it and the in degreeis the number of edges entering it. 2 2 3 3 1 1 4 4 The indegreeof vertex 2 is 2 and the out degreeof vertex 3 is 0 The degree of vertex 2 is 3
Adjacent/Neighbor Nodes If edgee={u,v} ∈ E, u and v areadjacentor neighbors 2 3 1 4 (1,2), (2,3), (2,4), (4,1) are all Adjacent/Neighbor Nodes
Weighted Graph A weighted graphis a graph for which each edge has an associated weight 2 2 2 1 5 4 6 3 3 1 1 2 9 8 3 4 4
Walks and Paths • 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 simplepath 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 3 V2 V3 1 2 3 V1 1 V6 4 4 V5 V4 1
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 Graphs • 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 B C A E F D A B C D
Bipartite Graph A bipartite graphis an undirected graphG = (V,E) in which V can be partitioned into 2 sets V1 and V2 such that (u,v) EimpliesuV1 and vV2or vice versa V1 V2 v11 v21 v12 v22 v13 v23 v14
Graph Representation: Adjacency Matrix Adjacency Matrixnn matrix with Auv = 1 if (u, v) is an edge • Symmetric matrix for undirectedgraphs (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 Adjacency List 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