Lecture 2: Network Representations

Total Page:16

File Type:pdf, Size:1020Kb

Lecture 2: Network Representations Math 5490 Network Flows Lecture 2: Network Representations Stephen Billups University of Colorado at Denver Math 5490Network Flows – p.1/18 Outline Notation and definitions. Network Representations. Assignment Readings: Read Sections 2.3-2.5 Reminder: HWK 1: Exercises 1.1, 1.2, 1.5, 1.7 (Due Next Tuesday (January 24)) Math 5490Network Flows – p.2/18 Notation and Definitions 1 2 4 5 3 6 1. What is the in-degree of node 2? 2. What is the out-degree of node 4? 3. What is the arc adjacency list for node 3? 4. What is the node adjacency list for node 5? Math 5490Network Flows – p.3/18 Notation and Definitions (cont) 1. What is the difference between a directed graph and a network? 2. What is the difference between a loop and cycle? 3. What is the difference between a walk, a path, and a cycle? 4. How many arcs are in a tree with n nodes? 5. What is the difference between a tree and a spanning tree? 6. Can an out-tree be undirected? 7. How do connected and acyclic relate to graphs and trees? Math 5490Network Flows – p.4/18 Default Assumptions Unless otherwise stated, we will make the following assumptions in this course: Graphs and networks are directed. No multiarcs or loops. n = number of nodes. m = number of arcs. Math 5490Network Flows – p.5/18 Network Representations Node-arc incidence matrix. Node-node adjacency matrix. Adjacency lists. Forward and reverse star representations. Math 5490Network Flows – p.6/18 Node-arc incidence matrix 1. Rows correspond to nodes, columns to arcs: 2. The column for arc (i; j) has exactly two non-zero entries: +1 in row i and −1 in row j. (1,2) (2,3) (2,4) (3,4) (3,5) (4,1) (4,2) (4,5) 1 1 0 0 0 0 −1 0 0 2 3 2 −1 1 1 0 0 0 −1 0 6 7 6 − 7 3 6 0 1 0 1 1 0 0 0 7 6 7 4 6 0 0 −1 −1 0 1 1 1 7 6 7 6 7 5 4 0 0 0 0 −1 0 0 −1 5 (c_ij, u_ij) i j (7,10) 2 3 (2,5) (9,50) (3,8) (4,20) (5,25) 1 5 (11,30) (4,50) 4 Figure 1 Math 5490Network Flows – p.7/18 Exercise Draw the graph corresponding to the following node-arc incidence matrix: 1 0 −1 0 0 1 2 3 0 0 1 0 1 0 6 7 6 7 6 0 1 0 −1 −1 0 7 6 7 6 7 4 −1 −1 0 1 0 −1 5 Math 5490Network Flows – p.8/18 Application to linear programming formulation Recall that a minimum cost flow problem has the following linear programming formulation: min P(i;j)2A cij xij subject to Pfjj (i;j)2A g xij − Pfjj (j;i)2A g xji = b(i) for all i 2 N. (node balance: flow out - flow in = supply) lij ≤ xij ≤ uij for all (i; j) 2 A. Using the node-arc-incidence matrix, we can write down the LP formulation more compactly as follows: min cT x subject to N x = b l ≤ x ≤ u where N is the node-arc-incidence matrix, and c, x, l, and u are vectors with components cij , xij , lij and uij , respectively, for (i; j) 2 A in some fixed order, and b = (b1; b2; : : : ; n). Math 5490Network Flows – p.9/18 Space-efficiency 1. Node-arc incidence matrix wastes a lot of space because most of the entries are zeros Math 5490Network Flows – p.10/18 Answer: 1 2 3 4 5 1 0 0 0 1 0 2 3 2 0 0 0 1 0 6 7 6 7 3 6 0 1 0 0 0 7 6 7 4 6 1 1 1 0 0 7 6 7 6 7 5 4 0 0 1 1 0 5 Node-node adjacency matrix 1. Rows and columns both correspond to nodes. 2. A ’1’ in position (i; j) indicates an arc going from node i to node j. Question: What is the node-node adjacency matrix for the graph shown in Fig. 1. Math 5490Network Flows – p.11/18 Node-node adjacency matrix 1. Rows and columns both correspond to nodes. 2. A ’1’ in position (i; j) indicates an arc going from node i to node j. Question: What is the node-node adjacency matrix for the graph shown in Fig. 1. Answer: 1 2 3 4 5 1 0 0 0 1 0 2 3 2 0 0 0 1 0 6 7 6 7 3 6 0 1 0 0 0 7 6 7 4 6 1 1 1 0 0 7 6 7 6 7 5 4 0 0 1 1 0 5 Math 5490Network Flows – p.11/18 Questions 1. If a graph has n nodes and m arcs, how many 1’s are in the adjacency matrix? How many 0’s? 2. In comparison, how many 1’s are in the node-arc incidence matrix? How many 0’s? 3. Suppose we wanted to identify all of arcs emanating from node i. How would you do that with each of these data structures? How much time would it take? Math 5490Network Flows – p.12/18 Comment on efficiency 1. Node-node adjacency matrix is space and time efficient only if network is dense. Math 5490Network Flows – p.13/18 Adjacency Lists 1. For each node i, the arc adjacency list A(i) is stored as a linked list. 2. Each record in the linked list corresponds to an arc (i; j), and stores the following info: (a) The head of the arc j (Why not the tail also?). (b) The cost cij . (c) The capacity bounds lij , uij . (d) A pointer to the next record in the linked list. 3. An array of pointers is used to store a pointer to the first record of each linked list. Math 5490Network Flows – p.14/18 Example Figure 2 illustrates the adjacency list representation of the network shown in Figure 1. i j c_ij u_ij 2 2 0 1 5 2 3 7 10 4 4 20 0 3 4 5 25 5 9 50 0 4 1 11 30 2 3 8 5 4 50 0 5 Figure 2: Adjacency list representation Math 5490Network Flows – p.15/18 Forward Star Representation Stores same information as adjacency list, but using arrays instead of linked lists. 1. Stores arc information in 4 (or 3 or 5) arrays: tail; head; cost and capacity. Each array has length m (the number of arcs). 2. (Important) The arcs must be ordered according in order of increasing tail nodes. 3. An additional array called point of length n (the number of nodes) is used to tell us where to look for arcs emanating from each node. Specifically, if node i has an arc emanating from it, then point(i) is the index of the first arc emanating from node i. If node i has no arcs emanating from it, then point(i) is set equal to point(i + 1). Math 5490Network Flows – p.16/18 Example The forward star representation for our example is as follows: tail head cost capacity 1 1 2 2 5 point 2 2 3 7 10 1 1 3 2 4 4 20 2 2 4 3 4 5 25 3 4 5 3 5 9 50 4 6 6 4 1 11 30 5 9 7 4 2 3 8 8 4 5 4 50 Math 5490Network Flows – p.17/18 Comparisons 1. Forward star representation requires less memory. 2. Forward star easier to implement, unless the language supports pointers (like C). 3. More difficult to add and delete arcs in forward star. (time is proportional to m, whereas adding or deleting arcs with adjacency lists requires only constant time). Math 5490Network Flows – p.18/18.
Recommended publications
  • Practical Parallel Hypergraph Algorithms
    Practical Parallel Hypergraph Algorithms Julian Shun [email protected] MIT CSAIL Abstract v While there has been signicant work on parallel graph pro- 0 cessing, there has been very surprisingly little work on high- e0 performance hypergraph processing. This paper presents v0 v1 v1 a collection of ecient parallel algorithms for hypergraph processing, including algorithms for betweenness central- e1 ity, maximal independent set, k-core decomposition, hyper- v2 trees, hyperpaths, connected components, PageRank, and v2 v3 e single-source shortest paths. For these problems, we either 2 provide new parallel algorithms or more ecient implemen- v3 tations than prior work. Furthermore, our algorithms are theoretically-ecient in terms of work and depth. To imple- (a) Hypergraph (b) Bipartite representation ment our algorithms, we extend the Ligra graph processing Figure 1. An example hypergraph representing the groups framework to support hypergraphs, and our implementa- , , , , , , and , , and its bipartite repre- { 0 1 2} { 1 2 3} { 0 3} tions benet from graph optimizations including switching sentation. between sparse and dense traversals based on the frontier size, edge-aware parallelization, using buckets to prioritize processing of vertices, and compression. Our experiments represented as hyperedges, can contain an arbitrary number on a 72-core machine and show that our algorithms obtain of vertices. Hyperedges correspond to group relationships excellent parallel speedups, and are signicantly faster than among vertices (e.g., a community in a social network). An algorithms in existing hypergraph processing frameworks. example of a hypergraph is shown in Figure 1a. CCS Concepts • Computing methodologies → Paral- Hypergraphs have been shown to enable richer analy- lel algorithms; Shared memory algorithms.
    [Show full text]
  • Quiz7 Problem 1
    Quiz 7 Quiz7 Problem 1. Independence The Problem. In the parts below, cite which tests apply to decide on independence or dependence. Choose one test and show complete details. 1 ! 1 ! (a) Vectors ~v = ;~v = 1 −1 2 1 0 1 1 0 1 1 0 1 1 B C B C B C (b) Vectors ~v1 = @ −1 A ;~v2 = @ 1 A ;~v3 = @ 0 A 0 −1 −1 2 5 (c) Vectors ~v1;~v2;~v3 are data packages constructed from the equations y = x ; y = x ; y = x10 on (−∞; 1). (d) Vectors ~v1;~v2;~v3 are data packages constructed from the equations y = 1 + x; y = 1 − x; y = x3 on (−∞; 1). Basic Test. To show three vectors are independent, form the system of equations c1~v1 + c2~v2 + c3~v3 = ~0; then solve for c1; c2; c3. If the only solution possible is c1 = c2 = c3 = 0, then the vectors are independent. Linear Combination Test. A list of vectors is independent if and only if each vector in the list is not a linear combination of the remaining vectors, and each vector in the list is not zero. Subset Test. Any nonvoid subset of an independent set is independent. The basic test leads to three quick independence tests for column vectors. All tests use the augmented matrix A of the vectors, which for 3 vectors is A =< ~v1j~v2j~v3 >. Rank Test. The vectors are independent if and only if rank(A) equals the number of vectors. Determinant Test. Assume A is square. The vectors are independent if and only if the deter- minant of A is nonzero.
    [Show full text]
  • Adjacency and Incidence Matrices
    Adjacency and Incidence Matrices 1 / 10 The Incidence Matrix of a Graph Definition Let G = (V ; E) be a graph where V = f1; 2;:::; ng and E = fe1; e2;:::; emg. The incidence matrix of G is an n × m matrix B = (bik ), where each row corresponds to a vertex and each column corresponds to an edge such that if ek is an edge between i and j, then all elements of column k are 0 except bik = bjk = 1. 1 2 e 21 1 13 f 61 0 07 3 B = 6 7 g 40 1 05 4 0 0 1 2 / 10 The First Theorem of Graph Theory Theorem If G is a multigraph with no loops and m edges, the sum of the degrees of all the vertices of G is 2m. Corollary The number of odd vertices in a loopless multigraph is even. 3 / 10 Linear Algebra and Incidence Matrices of Graphs Recall that the rank of a matrix is the dimension of its row space. Proposition Let G be a connected graph with n vertices and let B be the incidence matrix of G. Then the rank of B is n − 1 if G is bipartite and n otherwise. Example 1 2 e 21 1 13 f 61 0 07 3 B = 6 7 g 40 1 05 4 0 0 1 4 / 10 Linear Algebra and Incidence Matrices of Graphs Recall that the rank of a matrix is the dimension of its row space. Proposition Let G be a connected graph with n vertices and let B be the incidence matrix of G.
    [Show full text]
  • A Brief Introduction to Spectral Graph Theory
    A BRIEF INTRODUCTION TO SPECTRAL GRAPH THEORY CATHERINE BABECKI, KEVIN LIU, AND OMID SADEGHI MATH 563, SPRING 2020 Abstract. There are several matrices that can be associated to a graph. Spectral graph theory is the study of the spectrum, or set of eigenvalues, of these matrices and its relation to properties of the graph. We introduce the primary matrices associated with graphs, and discuss some interesting questions that spectral graph theory can answer. We also discuss a few applications. 1. Introduction and Definitions This work is primarily based on [1]. We expect the reader is familiar with some basic graph theory and linear algebra. We begin with some preliminary definitions. Definition 1. Let Γ be a graph without multiple edges. The adjacency matrix of Γ is the matrix A indexed by V (Γ), where Axy = 1 when there is an edge from x to y, and Axy = 0 otherwise. This can be generalized to multigraphs, where Axy becomes the number of edges from x to y. Definition 2. Let Γ be an undirected graph without loops. The incidence matrix of Γ is the matrix M, with rows indexed by vertices and columns indexed by edges, where Mxe = 1 whenever vertex x is an endpoint of edge e. For a directed graph without loss, the directed incidence matrix N is defined by Nxe = −1; 1; 0 corresponding to when x is the head of e, tail of e, or not on e. Definition 3. Let Γ be an undirected graph without loops. The Laplace matrix of Γ is the matrix L indexed by V (G) with zero row sums, where Lxy = −Axy for x 6= y.
    [Show full text]
  • Graph Equivalence Classes for Spectral Projector-Based Graph Fourier Transforms Joya A
    1 Graph Equivalence Classes for Spectral Projector-Based Graph Fourier Transforms Joya A. Deri, Member, IEEE, and José M. F. Moura, Fellow, IEEE Abstract—We define and discuss the utility of two equiv- Consider a graph G = G(A) with adjacency matrix alence graph classes over which a spectral projector-based A 2 CN×N with k ≤ N distinct eigenvalues and Jordan graph Fourier transform is equivalent: isomorphic equiv- decomposition A = VJV −1. The associated Jordan alence classes and Jordan equivalence classes. Isomorphic equivalence classes show that the transform is equivalent subspaces of A are Jij, i = 1; : : : k, j = 1; : : : ; gi, up to a permutation on the node labels. Jordan equivalence where gi is the geometric multiplicity of eigenvalue 휆i, classes permit identical transforms over graphs of noniden- or the dimension of the kernel of A − 휆iI. The signal tical topologies and allow a basis-invariant characterization space S can be uniquely decomposed by the Jordan of total variation orderings of the spectral components. subspaces (see [13], [14] and Section II). For a graph Methods to exploit these classes to reduce computation time of the transform as well as limitations are discussed. signal s 2 S, the graph Fourier transform (GFT) of [12] is defined as Index Terms—Jordan decomposition, generalized k gi eigenspaces, directed graphs, graph equivalence classes, M M graph isomorphism, signal processing on graphs, networks F : S! Jij i=1 j=1 s ! (s ;:::; s ;:::; s ;:::; s ) ; (1) b11 b1g1 bk1 bkgk I. INTRODUCTION where sij is the (oblique) projection of s onto the Jordan subspace Jij parallel to SnJij.
    [Show full text]
  • Network Properties Revealed Through Matrix Functions 697
    SIAM REVIEW c 2010 Society for Industrial and Applied Mathematics Vol. 52, No. 4, pp. 696–714 Network Properties Revealed ∗ through Matrix Functions † Ernesto Estrada Desmond J. Higham‡ Abstract. The emerging field of network science deals with the tasks of modeling, comparing, and summarizing large data sets that describe complex interactions. Because pairwise affinity data can be stored in a two-dimensional array, graph theory and applied linear algebra provide extremely useful tools. Here, we focus on the general concepts of centrality, com- municability,andbetweenness, each of which quantifies important features in a network. Some recent work in the mathematical physics literature has shown that the exponential of a network’s adjacency matrix can be used as the basis for defining and computing specific versions of these measures. We introduce here a general class of measures based on matrix functions, and show that a particular case involving a matrix resolvent arises naturally from graph-theoretic arguments. We also point out connections between these measures and the quantities typically computed when spectral methods are used for data mining tasks such as clustering and ordering. We finish with computational examples showing the new matrix resolvent version applied to real networks. Key words. centrality measures, clustering methods, communicability, Estrada index, Fiedler vector, graph Laplacian, graph spectrum, power series, resolvent AMS subject classifications. 05C50, 05C82, 91D30 DOI. 10.1137/090761070 1. Motivation. 1.1. Introduction. Connections are important. Across the natural, technologi- cal, and social sciences it often makes sense to focus on the pattern of interactions be- tween individual components in a system [1, 8, 61].
    [Show full text]
  • Incidence Matrices and Interval Graphs
    Pacific Journal of Mathematics INCIDENCE MATRICES AND INTERVAL GRAPHS DELBERT RAY FULKERSON AND OLIVER GROSS Vol. 15, No. 3 November 1965 PACIFIC JOURNAL OF MATHEMATICS Vol. 15, No. 3, 1965 INCIDENCE MATRICES AND INTERVAL GRAPHS D. R. FULKERSON AND 0. A. GROSS According to present genetic theory, the fine structure of genes consists of linearly ordered elements. A mutant gene is obtained by alteration of some connected portion of this structure. By examining data obtained from suitable experi- ments, it can be determined whether or not the blemished portions of two mutant genes intersect or not, and thus inter- section data for a large number of mutants can be represented as an undirected graph. If this graph is an "interval graph," then the observed data is consistent with a linear model of the gene. The problem of determining when a graph is an interval graph is a special case of the following problem concerning (0, l)-matrices: When can the rows of such a matrix be per- muted so as to make the l's in each column appear consecu- tively? A complete theory is obtained for this latter problem, culminating in a decomposition theorem which leads to a rapid algorithm for deciding the question, and for constructing the desired permutation when one exists. Let A — (dij) be an m by n matrix whose entries ai3 are all either 0 or 1. The matrix A may be regarded as the incidence matrix of elements el9 e2, , em vs. sets Sl9 S2, , Sn; that is, ai3 = 0 or 1 ac- cording as et is not or is a member of S3 .
    [Show full text]
  • Practical Parallel Hypergraph Algorithms
    Practical Parallel Hypergraph Algorithms Julian Shun [email protected] MIT CSAIL Abstract v0 While there has been significant work on parallel graph pro- e0 cessing, there has been very surprisingly little work on high- v0 v1 v1 performance hypergraph processing. This paper presents a e collection of efficient parallel algorithms for hypergraph pro- 1 v2 cessing, including algorithms for computing hypertrees, hy- v v 2 3 e perpaths, betweenness centrality, maximal independent sets, 2 v k-core decomposition, connected components, PageRank, 3 and single-source shortest paths. For these problems, we ei- (a) Hypergraph (b) Bipartite representation ther provide new parallel algorithms or more efficient imple- mentations than prior work. Furthermore, our algorithms are Figure 1. An example hypergraph representing the groups theoretically-efficient in terms of work and depth. To imple- fv0;v1;v2g, fv1;v2;v3g, and fv0;v3g, and its bipartite repre- ment our algorithms, we extend the Ligra graph processing sentation. framework to support hypergraphs, and our implementations benefit from graph optimizations including switching between improved compared to using a graph representation. Unfor- sparse and dense traversals based on the frontier size, edge- tunately, there is been little research on parallel hypergraph aware parallelization, using buckets to prioritize processing processing. of vertices, and compression. Our experiments on a 72-core The main contribution of this paper is a suite of efficient machine and show that our algorithms obtain excellent paral- parallel hypergraph algorithms, including algorithms for hy- lel speedups, and are significantly faster than algorithms in pertrees, hyperpaths, betweenness centrality, maximal inde- existing hypergraph processing frameworks.
    [Show full text]
  • Diagonal Sums of Doubly Stochastic Matrices Arxiv:2101.04143V1 [Math
    Diagonal Sums of Doubly Stochastic Matrices Richard A. Brualdi∗ Geir Dahl† 7 December 2020 Abstract Let Ωn denote the class of n × n doubly stochastic matrices (each such matrix is entrywise nonnegative and every row and column sum is 1). We study the diagonals of matrices in Ωn. The main question is: which A 2 Ωn are such that the diagonals in A that avoid the zeros of A all have the same sum of their entries. We give a characterization of such matrices, and establish several classes of patterns of such matrices. Key words. Doubly stochastic matrix, diagonal sum, patterns. AMS subject classifications. 05C50, 15A15. 1 Introduction Let Mn denote the (vector) space of real n×n matrices and on this space we consider arXiv:2101.04143v1 [math.CO] 11 Jan 2021 P the usual scalar product A · B = i;j aijbij for A; B 2 Mn, A = [aij], B = [bij]. A permutation σ = (k1; k2; : : : ; kn) of f1; 2; : : : ; ng can be identified with an n × n permutation matrix P = Pσ = [pij] by defining pij = 1, if j = ki, and pij = 0, otherwise. If X = [xij] is an n × n matrix, the entries of X in the positions of X in ∗Department of Mathematics, University of Wisconsin, Madison, WI 53706, USA. [email protected] †Department of Mathematics, University of Oslo, Norway. [email protected]. Correspond- ing author. 1 which P has a 1 is the diagonal Dσ of X corresponding to σ and P , and their sum n X dP (X) = xi;ki i=1 is a diagonal sum of X.
    [Show full text]
  • The Generalized Dedekind Determinant
    Contemporary Mathematics Volume 655, 2015 http://dx.doi.org/10.1090/conm/655/13232 The Generalized Dedekind Determinant M. Ram Murty and Kaneenika Sinha Abstract. The aim of this note is to calculate the determinants of certain matrices which arise in three different settings, namely from characters on finite abelian groups, zeta functions on lattices and Fourier coefficients of normalized Hecke eigenforms. Seemingly disparate, these results arise from a common framework suggested by elementary linear algebra. 1. Introduction The purpose of this note is three-fold. We prove three seemingly disparate results about matrices which arise in three different settings, namely from charac- ters on finite abelian groups, zeta functions on lattices and Fourier coefficients of normalized Hecke eigenforms. In this section, we state these theorems. In Section 2, we state a lemma from elementary linear algebra, which lies at the heart of our three theorems. A detailed discussion and proofs of the theorems appear in Sections 3, 4 and 5. In what follows below, for any n × n matrix A and for 1 ≤ i, j ≤ n, Ai,j or (A)i,j will denote the (i, j)-th entry of A. A diagonal matrix with diagonal entries y1,y2, ...yn will be denoted as diag (y1,y2, ...yn). Theorem 1.1. Let G = {x1,x2,...xn} be a finite abelian group and let f : G → C be a complex-valued function on G. Let F be an n × n matrix defined by F −1 i,j = f(xi xj). For a character χ on G, (that is, a homomorphism of G into the multiplicative group of the field C of complex numbers), we define Sχ := f(s)χ(s).
    [Show full text]
  • Dynamical Systems Associated with Adjacency Matrices
    DISCRETE AND CONTINUOUS doi:10.3934/dcdsb.2018190 DYNAMICAL SYSTEMS SERIES B Volume 23, Number 5, July 2018 pp. 1945{1973 DYNAMICAL SYSTEMS ASSOCIATED WITH ADJACENCY MATRICES Delio Mugnolo Delio Mugnolo, Lehrgebiet Analysis, Fakult¨atMathematik und Informatik FernUniversit¨atin Hagen, D-58084 Hagen, Germany Abstract. We develop the theory of linear evolution equations associated with the adjacency matrix of a graph, focusing in particular on infinite graphs of two kinds: uniformly locally finite graphs as well as locally finite line graphs. We discuss in detail qualitative properties of solutions to these problems by quadratic form methods. We distinguish between backward and forward evo- lution equations: the latter have typical features of diffusive processes, but cannot be well-posed on graphs with unbounded degree. On the contrary, well-posedness of backward equations is a typical feature of line graphs. We suggest how to detect even cycles and/or couples of odd cycles on graphs by studying backward equations for the adjacency matrix on their line graph. 1. Introduction. The aim of this paper is to discuss the properties of the linear dynamical system du (t) = Au(t) (1.1) dt where A is the adjacency matrix of a graph G with vertex set V and edge set E. Of course, in the case of finite graphs A is a bounded linear operator on the finite di- mensional Hilbert space CjVj. Hence the solution is given by the exponential matrix etA, but computing it is in general a hard task, since A carries little structure and can be a sparse or dense matrix, depending on the underlying graph.
    [Show full text]
  • Adjacency Matrix
    CSE 373 Graphs 3: Implementation reading: Weiss Ch. 9 slides created by Marty Stepp http://www.cs.washington.edu/373/ © University of Washington, all rights reserved. 1 Implementing a graph • If we wanted to program an actual data structure to represent a graph, what information would we need to store? for each vertex? for each edge? 1 2 3 • What kinds of questions would we want to be able to answer quickly: 4 5 6 about a vertex? about edges / neighbors? 7 about paths? about what edges exist in the graph? • We'll explore three common graph implementation strategies: edge list , adjacency list , adjacency matrix 2 Edge list • edge list : An unordered list of all edges in the graph. an array, array list, or linked list • advantages : 1 2 3 easy to loop/iterate over all edges 4 5 6 • disadvantages : hard to quickly tell if an edge 7 exists from vertex A to B hard to quickly find the degree of a vertex (how many edges touch it) 0 1 2 3 4 56 7 8 (1, 2) (1, 4) (1, 7) (2, 3) 2, 5) (3, 6)(4, 7) (5, 6) (6, 7) 3 Graph operations • Using an edge list, how would you find: all neighbors of a given vertex? the degree of a given vertex? whether there is an edge from A to B? 1 2 3 whether there are any loops (self-edges)? • What is the Big-Oh of each operation? 4 5 6 7 0 1 2 3 4 56 7 8 (1, 2) (1, 4) (1, 7) (2, 3) 2, 5) (3, 6)(4, 7) (5, 6) (6, 7) 4 Adjacency matrix • adjacency matrix : An N × N matrix where: the non-diagonal entry a[i,j] is the number of edges joining vertex i and vertex j (or the weight of the edge joining vertex i and vertex j).
    [Show full text]