Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Adjacency matrix

From Wikipedia, the free encyclopedia
Square matrix used to represent a graph or network

Ingraph theory andcomputer science, anadjacency matrix is asquare matrix used to represent a finitegraph. The elements of thematrix indicate whether pairs ofvertices areadjacent or not within the graph.

In the special case of a finitesimple graph, the adjacency matrix is a(0,1)-matrix with zeros on its diagonal. If the graph isundirected (i.e. all of itsedges are bidirectional), the adjacency matrix issymmetric. The relationship between a graph and theeigenvalues andeigenvectors of its adjacency matrix is studied inspectral graph theory.

The adjacency matrix of a graph should be distinguished from itsincidence matrix, a different matrix representation whose elements indicate whether vertex–edge pairs areincident or not, and itsdegree matrix, which contains information about thedegree of each vertex.

Definition

[edit]

For a simple graph with vertex setU = {u1, ...,un}, the adjacency matrix is a squaren ×n matrixA such that its elementAij is 1 when there is an edge from vertexui to vertexuj, and 0 when there is no edge.[1] The diagonal elements of the matrix are all 0, since edges from a vertex to itself (loops) are not allowed in simple graphs. It is also sometimes useful inalgebraic graph theory to replace the nonzero elements with algebraic variables.[2] The same concept can be extended tomultigraphs and graphs with loops by storing the number of edges between each two vertices in the corresponding matrix element, and by allowing nonzero diagonal elements. Loops may be counted either once (as a single edge) or twice (as two vertex-edge incidences), as long as a consistent convention is followed. Undirected graphs often use the latter convention of counting loops twice, whereas directed graphs typically use the former convention.

Of a bipartite graph

[edit]

The adjacency matrixA of abipartite graph whose two parts haver ands vertices can be written in the form

A=(0r,rBBT0s,s),{\displaystyle A={\begin{pmatrix}0_{r,r}&B\\B^{\mathsf {T}}&0_{s,s}\end{pmatrix}},}

whereB is anr ×s matrix, and0r,r and0s,s represent ther ×r ands ×szero matrices. In this case, the smaller matrixB uniquely represents the graph, and the remaining parts ofA can be discarded as redundant.B is sometimes called thebiadjacency matrix.

Formally, letG = (U,V,E) be abipartite graph with partsU = {u1, ...,ur},V = {v1, ...,vs} and edgesE. The biadjacency matrix is ther ×s 0–1 matrixB in whichbi,j = 1if and only if(ui,vj) ∈E.

IfG is a bipartitemultigraph orweighted graph, then the elementsbi,j are taken to be the number of edges between the vertices or the weight of the edge(ui,vj), respectively.

Variations

[edit]

An(a,b,c)-adjacency matrixA of a simple graph hasAi,j =a if(i,j) is an edge,b if it is not, andc on the diagonal. TheSeidel adjacency matrix is a(−1, 1, 0)-adjacency matrix. This matrix is used in studyingstrongly regular graphs andtwo-graphs.[3]

Thedistance matrix has in position(i,j) the distance between verticesvi andvj. The distance is the length of a shortest path connecting the vertices. Unless lengths of edges are explicitly provided, the length of a path is the number of edges in it. The distance matrix resembles a high power of the adjacency matrix, but instead of telling only whether or not two vertices are connected (i.e., the connection matrix, which containsBoolean values), it gives the exact distance between them.

Examples

[edit]

Undirected graphs

[edit]

The convention followed here (for undirected graphs) is that each edge adds 1 to the appropriate cell in the matrix, and each loop (an edge from a vertex to itself) adds 2 to the appropriate cell on the diagonal in the matrix.[4] This allows the degree of a vertex to be easily found by taking the sum of the values in either its respective row or column in the adjacency matrix.

Labeled graphAdjacency matrix
(210010101010010100001011110100000100){\displaystyle {\begin{pmatrix}2&1&0&0&1&0\\1&0&1&0&1&0\\0&1&0&1&0&0\\0&0&1&0&1&1\\1&1&0&1&0&0\\0&0&0&1&0&0\end{pmatrix}}}


Coordinates are 1–6.


Nauru graph


Coordinates are 0–23.
White fields are zeros, colored fields are ones.

Directed graphs

[edit]

The adjacency matrix of a directed graph can be asymmetric. One can define the adjacency matrix of a directed graph either such that

  1. a non-zero elementAij indicates an edge fromi toj or
  2. it indicates an edge fromj toi.

The former definition is commonly used in graph theory and social network analysis (e.g., sociology, political science, economics, psychology).[5] The latter is more common in other applied sciences (e.g., dynamical systems, physics, network science) whereA is sometimes used to describe linear dynamics on graphs.[6]

Using the first definition, thein-degrees of a vertex can be computed by summing the entries of the corresponding column and the out-degree of vertex by summing the entries of the corresponding row. When using the second definition, the in-degree of a vertex is given by the corresponding row sum and the out-degree is given by the corresponding column sum.

Labeled graphAdjacency matrix


DirectedCayley graph ofS4


Coordinates are 0–23.
As the graph is directed, the matrix is not necessarilysymmetric.

Trivial graphs

[edit]

The adjacency matrix of acomplete graph contains all ones except along the diagonal where there are only zeros. The adjacency matrix of anempty graph is azero matrix.

Properties

[edit]

Spectrum

[edit]

The adjacency matrix of an undirected simple graph issymmetric, and therefore has a complete set ofrealeigenvalues and an orthogonaleigenvector basis. The set of eigenvalues of a graph is thespectrum of the graph.[7] It is common to denote the eigenvalues byλ1λ2λn.{\displaystyle \lambda _{1}\geq \lambda _{2}\geq \cdots \geq \lambda _{n}.}

The greatest eigenvalueλ1{\displaystyle \lambda _{1}} is bounded above by the maximum degree. This can be seen as result of thePerron–Frobenius theorem, but it can be proved easily. Letv be one eigenvector associated toλ1{\displaystyle \lambda _{1}} andx the entry in whichv has maximum absolute value. Without loss of generality assumevx is positive since otherwise you simply take the eigenvector -v, also associated toλ1{\displaystyle \lambda _{1}}. Then

λ1vx=(Av)x=y=1nAx,yvyy=1nAx,yvx=vxdeg(x).{\displaystyle \lambda _{1}v_{x}=(Av)_{x}=\sum _{y=1}^{n}A_{x,y}v_{y}\leq \sum _{y=1}^{n}A_{x,y}v_{x}=v_{x}\deg(x).}

Ford-regular graphs,d is the first eigenvalue ofA for the vectorv = (1, ..., 1) (it is easy to check that it is an eigenvalue and it is the maximum because of the above bound). The multiplicity of this eigenvalue is the number of connected components ofG, in particularλ1>λ2{\displaystyle \lambda _{1}>\lambda _{2}} for connected graphs. It can be shown that for each eigenvalueλi{\displaystyle \lambda _{i}}, its oppositeλi=λn+1i{\displaystyle -\lambda _{i}=\lambda _{n+1-i}} is also an eigenvalue ofA ifG is abipartite graph.[8] In particular −d is an eigenvalue of anyd-regular bipartite graph.

The differenceλ1λ2{\displaystyle \lambda _{1}-\lambda _{2}} is called thespectral gap and it is related to theexpansion ofG. It is also useful to introduce thespectral radius ofA{\displaystyle A} denoted byλ(G)=max|λi|<d|λi|{\displaystyle \lambda (G)=\max _{\left|\lambda _{i}\right|<d}|\lambda _{i}|}. This number is bounded byλ(G)2d1o(1){\displaystyle \lambda (G)\geq 2{\sqrt {d-1}}-o(1)}. This bound is tight in theRamanujan graphs.

Isomorphism and invariants

[edit]

Suppose two directed or undirected graphsG1 andG2 with adjacency matricesA1 andA2 are given.G1 andG2 areisomorphic if and only if there exists apermutation matrixP such that

PA1P1=A2.{\displaystyle PA_{1}P^{-1}=A_{2}.}

In particular,A1 andA2 aresimilar and therefore have the sameminimal polynomial,characteristic polynomial,eigenvalues,determinant andtrace. These can therefore serve as isomorphism invariants of graphs. However, two graphs may possess the same set of eigenvalues but not be isomorphic.[9] Suchlinear operators are said to beisospectral.

Matrix powers

[edit]

IfA is the adjacency matrix of the directed or undirected graphG, then the matrixAn (i.e., thematrix product ofn copies ofA) has an interesting interpretation: the element(i,j) gives the number of (directed or undirected)walks of lengthn from vertexi to vertexj.[10] Ifn is the smallest nonnegative integer, such that for somei,j, the element(i,j) ofAn is positive, thenn is the distance between vertexi and vertexj. A great example of how this is useful is in counting the number of triangles in an undirected graphG, which is exactly thetrace ofA3 divided by 3 or 6 depending on whether the graph is directed or not. We divide by those values to compensate for the overcounting of each triangle. In an undirected graph, each triangle will be counted twice for all three nodes, because the path can be followed clockwise or counterclockwise : ijk or ikj. The adjacency matrix can be used to determine whether or not the graph isconnected.

If a directed graph has anilpotent adjacency matrix (i.e., if there existsn such thatAn is the zero matrix), then it is adirected acyclic graph.[11]

Data structures

[edit]

The adjacency matrix may be used as adata structure for therepresentation of graphs in computer programs for manipulating graphs.Boolean data types are used, such asTrue andFalse inPython. The main alternative data structure, also in use for this application, is theadjacency list.[12][13]

The space needed to represent an adjacency matrix and the time needed to perform operations on them is dependent on thematrix representation chosen for the underlying matrix.Sparse matrix representations only store non-zero matrix entries and implicitly represent the zero entries. They can, for example, be used to representsparse graphs without incurring the space overhead from storing the many zero entries in the adjacency matrix of the sparse graph. In the following section the adjacency matrix is assumed to be represented by anarray data structure so that zero and non-zero entries are all directly represented in storage.

Because each entry in the adjacency matrix requires only one bit, it can be represented in a very compact way, occupying only|V|2 / 8 bytes to represent a directed graph, or (by using a packed triangular format and only storing the lower triangular part of the matrix) approximately|V|2 / 16 bytes to represent an undirected graph. Although slightly more succinct representations are possible, this method gets close to the information-theoretic lower bound for the minimum number of bits needed to represent alln-vertex graphs.[14] For storing graphs intext files, fewer bits per byte can be used to ensure that all bytes are text characters, for instance by using aBase64 representation.[15] Besides avoiding wasted space, this compactness encourageslocality of reference.However, for a largesparse graph, adjacency lists require less storage space, because they do not waste any space representing edges that arenot present.[13][16]

An alternative form of adjacency matrix (which, however, requires a larger amount of space) replaces the numbers in each element of the matrix with pointers to edge objects (when edges are present) or null pointers (when there is no edge).[16] It is also possible to storeedge weights directly in the elements of an adjacency matrix.[13]

Besides the space tradeoff, the different data structures also facilitate different operations. Finding all vertices adjacent to a given vertex in an adjacency list is as simple as reading the list, and takes time proportional to the number of neighbors. With an adjacency matrix, an entire row must instead be scanned, which takes a larger amount of time, proportional to the number of vertices in the whole graph. On the other hand, testing whether there is an edge between two given vertices can be determined at once with an adjacency matrix, while requiring time proportional to the minimum degree of the two vertices with the adjacency list.[13][16]

See also

[edit]

References

[edit]
  1. ^Biggs, Norman (1993),Algebraic Graph Theory, Cambridge Mathematical Library (2nd ed.), Cambridge University Press, Definition 2.1, p. 7.
  2. ^Harary, Frank (1962), "The determinant of the adjacency matrix of a graph",SIAM Review,4 (3):202–210,Bibcode:1962SIAMR...4..202H,doi:10.1137/1004057,MR 0144330.
  3. ^Seidel, J. J. (1968). "Strongly Regular Graphs with (−1, 1, 0) Adjacency Matrix Having Eigenvalue 3".Lin. Alg. Appl.1 (2):281–298.doi:10.1016/0024-3795(68)90008-6.
  4. ^Shum, Kenneth; Blake, Ian (2003-12-18)."Expander graphs and codes".Volume 68 of DIMACS series in discrete mathematics and theoretical computer science. Algebraic Coding Theory and Information Theory: DIMACS Workshop, Algebraic Coding Theory and Information Theory. American Mathematical Society. p. 63.ISBN 9780821871102.
  5. ^Borgatti, Steve; Everett, Martin; Johnson, Jeffrey (2018),Analyzing Social Networks (2nd ed.), SAGE, p. 20
  6. ^Newman, Mark (2018),Networks (2nd ed.), Oxford University Press, p. 110
  7. ^Biggs (1993), Chapter 2 ("The spectrum of a graph"), pp. 7–13.
  8. ^Brouwer, Andries E.; Haemers, Willem H. (2012),"1.3.6 Bipartite graphs",Spectra of Graphs, Universitext, New York: Springer, pp. 6–7,doi:10.1007/978-1-4614-1939-6,ISBN 978-1-4614-1938-9,MR 2882891
  9. ^Godsil, Chris;Royle, GordonAlgebraic Graph Theory, Springer (2001),ISBN 0-387-95241-1, p.164
  10. ^https://people.computing.clemson.edu/~goddard/texts/graphTheory/fullset.pdf
  11. ^Nicholson, Victor A. (1975-01-01)."Matrices with permanent equal to one".Linear Algebra and its Applications.12 (2): 187.doi:10.1016/0024-3795(75)90067-1.ISSN 0024-3795.
  12. ^Goodrich & Tamassia (2015), p. 361: "There are two data structures that people often use to represent graphs, the adjacency list and the adjacency matrix."
  13. ^abcdCormen, Thomas H.;Leiserson, Charles E.;Rivest, Ronald L.;Stein, Clifford (2001), "Section 22.1: Representations of graphs",Introduction to Algorithms (Second ed.), MIT Press and McGraw-Hill, pp. 527–531,ISBN 0-262-03293-7.
  14. ^Turán, György (1984), "On the succinct representation of graphs",Discrete Applied Mathematics,8 (3):289–294,doi:10.1016/0166-218X(84)90126-4,MR 0749658.
  15. ^McKay, Brendan,Description of graph6 and sparse6 encodings,archived from the original on 2001-04-30, retrieved2012-02-10.
  16. ^abcGoodrich, Michael T.;Tamassia, Roberto (2015),Algorithm Design and Applications, Wiley, p. 363.

External links

[edit]
Wikimedia Commons has media related toAdjacency matrices of graphs.
Graph representations
Data structures
XML-based formats
Text-based formats
Related concepts
Matrix classes
Explicitly constrained entries
Constant
Conditions oneigenvalues or eigenvectors
Satisfying conditions onproducts orinverses
With specific applications
Used instatistics
Used ingraph theory
Used in science and engineering
Related terms
Authority control databasesEdit this at Wikidata
Retrieved from "https://en.wikipedia.org/w/index.php?title=Adjacency_matrix&oldid=1323851955"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp