Graph theory - basic concepts and data structures of graphs

Basic concept of graph

Undirected graph

Edges have no direction, that is, bidirectional

image-20230529214724983

结点V = { v 1 , v 2 , . . . , v 7 } \mathcal{V} = \{ v_1,v_2,...,v_7\}V={ v1,v2,...,v7}

ε = { and 1 , 2 , and 1 , 3 , . . . , e 6 , 7 } \varepsilon = \{e_{1,2},e_{1,3},...,e_{6,7}\}e={ e1,2,e1,3,...,e6,7}

G = { V , ε } \mathcal{G} = \{ \mathcal{V},\varepsilon \}G={ V,e }

directed graph

Edges are directional, that is, unidirectional

image-20230529215534915

Unweighted graph

The edge has no weight, which can also be understood as the weight is 1

image-20230529215639069

entitled figure

Edges have weights

image-20230529215708278

Graph Data Structure

Adjacency matrix and adjacency list

undirected unweighted graph

image-20230529215708278
Adjacency list

Indicates who the node is connected to,

vertex Neighbors
1 2,3,4
2 1,4
3 1,4,6
4 1,2,3
5 empty
6 3,7
7 6
Adjacency matrix

[ 0 1 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 ] \begin{bmatrix} 0 & 1& 1& 1& 0& 0& 0\\ 1 & 0& 0& 1& 0& 0& 0\\ 1 & 0& 0& 1& 0& 1& 0\\ 1 & 1& 1& 0& 0& 0& 0\\ 0 & 0& 0& 0& 0& 0& 0\\ 0 & 0& 1& 0& 0& 0& 1\\ 0 & 0& 0& 0& 0& 1& 0 \end{bmatrix} 0111000100100010010101110000000000000100010000010

The adjacency matrix represents the nodes iii and nodejjThe weight between j , if it is an unweighted graph, the weight is 1. The adjacency matrices of undirected graphs are all symmetric. Because edges are bidirectional.

directed unweighted graph

Adjacency list

Indicates who the node is connected to,

vertex Neighbors
1 2,4
2 4,5
3 1,6
4 5
5 empty
6 7
7 6
Adjacency matrix

[ 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 ] \begin{bmatrix} 0 & 1& 0& 1& 0& 0& 0\\ 0 & 0& 0& 1& 1& 0& 0\\ 1 & 0& 0& 0& 0& 1& 0\\ 0 & 0& 0& 0& 0& 1& 0\\ 0 & 0& 0& 0& 0& 0& 0\\ 0 & 0& 0& 0& 0& 0& 1\\ 0 & 0& 0& 0& 0& 1& 0 \end{bmatrix} 0010000100000000000001100000010000000110010000010

The adjacency matrix represents the nodes iii and nodejjThe weight between j . The list shows the starting point, and the row shows the reached point, such asa 1 , 2 = 1 a_{1,2} = 1a1,2=1 means there is a unidirectional edge from node 1 to node 2.

entitled figure

insert image description here

Adjacency matrix

[ 0 2 4 1 0 0 0 2 0 0 3 0 0 0 4 0 2 0 0 5 0 1 3 2 0 0 1 0 0 0 0 0 0 0 0 0 0 5 0 0 0 1 0 0 0 0 0 1 0 ] \begin{bmatrix} 0 & 2& 4& 1& 0& 0& 0\\ 2 & 0& 0& 3& 0& 0& 0\\ 4 & 0& 2& 0& 0& 5& 0\\ 1 & 3& 2& 0& 0& 1& 0\\ 0 & 0& 0& 0& 0& 0& 0\\ 0 & 0& 5& 0& 0& 0& 1\\ 0 & 0& 0& 0& 0& 1& 0 \end{bmatrix} 0241000200300040220501300000000000000510010000010

In fact, it is very similar to an undirected graph, which means the link between two nodes. The weighted graph has weights, but the unweighted graph does not.

degree matrix

The degree matrix is ​​an important concept in graph theory, which is used to describe the degree of each node in an undirected or directed graph. It is a diagonal matrix, the elements di d_i in the matrixdirepresents node iidegree of i , i.e. with nodeiii is the number of connected edges.

Undirected graph

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ] \begin{bmatrix} 3 & 0& 0& 0& 0& 0& 0\\ 0 & 2& 0& 0& 0& 0& 0\\ 0 & 0& 3& 0& 0& 0& 0\\ 0 & 0& 0& 3& 0& 0& 0 \\ 0 & 0& 0& 0& 0& 0& 0\\ 0 & 0& 0& 0& 0& 2& 0\\ 0 & 0& 0& 0& 0& 0& 1 \end{bmatrix} 3000000020000000300000003000000000000000200000001
It can be seen that is a diagonal matrix.

directed graph

For directed graphs, it can be divided into out-degree matrix and in-degree matrix. The out-degree matrix represents the out-degree of each node, and the in-degree matrix represents the in-degree of each node. This is easy to calculate, not in the demonstration

Laplacian matrix

The Laplacian matrix is ​​used to describe the properties of graphs. There are generally several methods for calculating the Laplacian matrix

1. Symmetric normalized Laplacian: Let L be the Laplacian matrix of graph G, D be the degree matrix, then the symmetric normalized Laplacian matrix is ​​L sym = D − 1 2 LD − 1 2 L_{sym}= D^{-\frac{1}{2}}LD^{-\frac{1}{2}}Lsym=D21LD21

2、Random walk Laplacian:设 M = D − 1 L M=D^{-1}L M=D1 L, then the random walk Laplacian matrix is​​L rwl = I − M L_{rwl} = IMLr wl=IM ,III is the identity matrix.

3. Unnormalized Laplacian: The Laplacian matrix without normalization can be expressed as L = D − AL=DAL=DA , where A is the adjacency matrix and D is the degree matrix

Matrix properties[1]

  • 0 is his eigenvalue, 1 N 1_N1Nis the eigenvector

  • x T ℓ x = 1 2 ∑ i = 1 N ∑ j = 1 N a i j ( x j − x i ) 2 x^T\ell x=\frac{1}{2} \sum_{i=1}^{N} \sum_{j=1}^{N} a_{ij}(x_j-x_i)^2 xTx=21i=1Nj=1Naij(xjxi)2ℓ \heThe positive semi-definiteness of means that ℓ \ellAll characteristic roots of ℓ are real and nonnegative

  • If G is connected, then ℓ \ellThe second smallest characteristic root of , you can use λ 2 ( ℓ ) \lambda_2(\ell)l2( ) , called the algebraic connectivity of G, which is greater than 0

  • The algebraic connectivity of G is equal to minx ≠ 0 , 1 NT x = 0 x T ℓ xx T x min_{x \ne 0,1_N^Tx=0} \frac{x^T \ell x}{x^T x}minx=0,1NTx=0xTxxTx, so if $1_N^T x = 0,x^T \ell x \ge \lambda_2(\ell)x^Tx $ .

references

[1] R. Olfati-Saber, R.M. Murray, Consensus problems in networks of agents with switching topology and time-delays. IEEE Trans. Autom. Control 49(9), 1520–1533 (2004)

The pictures in this article are from the course of Mr. Wang Shusen. The course has not been carefully studied, and only these basic knowledge are needed.

Guess you like

Origin blog.csdn.net/weixin_43903639/article/details/130938161