Reprinted from: http://www.cnblogs.com/skywang12345/p/3691463.html

**Basic concepts of Ⅰ graphs**
**1. Definition of diagram**

Definition: Graph (graph) is composed of some points (vertex) and the connection (edge) between these points, where the point is usually the "vertex (vertex)", and the connection between the point and point becomes "Edge or arc" (Edege). It is usually written as g= (V,e).

**2. Types of graphs**

Depending on whether the edge has a direction, the graph can be divided into: **no map** and **directed graph** .

**2.1 Graph without direction**

The above figure G0 is a non-directed graph, and all the edges of the non-directed graph are non-distinguishing directions. G0= (V1,{e1}). which

**(** v1={a,b,c,d,e,f}). V1 represents a collection of vertices consisting of "a,b,c,d,e,f".

(e1={), (b), (A,c), (B,c), (B,e), (b,f), (c,f), (C,d), (e,f), (C,e)}. E1 is by side (A, b), side (a,c) ... And so forth the composition of the collection. Where (A,c) represents an edge connected by vertex A and vertex C.

**2.2 Direction diagram**

The above figure G2 is a forward graph. Unlike the non-directed graph, all sides of the directed graph have directions! G2= (V2,{a2}). which

**(** v2={a,c,b,f,d,e,g}). V2 represents a collection of vertices consisting of "a,b,c,d,e,f,g".

**(a2={<a,b>,<b,c>,<b,f>,<b,e>,<c,e>,<e,d>,<d,c>,<e,b)** >,<f,g>}. E1 is by vector <a,b>, vector <b,c> And so forth the composition of the collection. where Vector <a,b) represents a directed edge from vertex A to vertex c.

**3. Adjacency Points and degrees**

**3.1 adjacency points**

The two vertices on an edge are called adjacency points.

For example, vertex A and vertex C in the G0 diagram above are the adjacency points.

In a forward graph, in addition to the adjacency point, there is the concept of "in-edge" and "out-side".

The in edge of a vertex is the edge that ends at that vertex. And the edge of the vertex is the side that starts with the vertex.

For example, whether B and E in the graph G2 above are the adjacency point;<b,e> the out edge of B, or the incoming edge of E.

**3.2 Degrees**

In an no-map, the degree of a vertex is the number of edges (or arcs) that are adjacent to that vertex.

For example, the degree of vertex a in the G0 graph above is 2.

In the direction graph, the degree also has the "in degree" and "the degree" the cent.

The degree to which a vertex is entered is the number of edges with that vertex as the end point. The degree of the vertex is the number of edges that start with the vertex.

The degree of the vertex = the In + out degree.

For example, in the graph G2 above, the degree of vertex B is 2, the out degree is 3, and the degree of Vertex B is =2+3=5.

**4. Paths and Loops**

**path** : If a vertex sequence exists between vertex (Vm) to Vertex (Vn). Indicates that the VM to VN is a path.

**path length** : The number of edges in the path.

**Simple Path** : A simple path if vertices on one path do not recur.

**Loop** : If the first vertex of a path is the same as the last vertex, it is a loop.

**simple** Loop: The first vertex is the same as the last vertex, and the loop that does not repeat the other vertices is a simple one.

**5. Connected graphs and connected components**

**Connected graphs** : For undirected graphs, there is an undirected path between any two vertices, it is said that the undirected graph is a connected graph. For an undirected graph, if there is a direction path between any two vertices in the graph, the graph is said to be strongly connected.

**Connected Components** : Each connected sub-graph in a non-connected graph is called the connected component of the graph.

**6. Rights**

When learning "Huffman Tree", the concept of "power" has been known. The concept of right in the picture is similar to this.

The above is a weighted graph.

**storage structure of Ⅱ graphs**
The basic concepts of graphs are described above, and the storage structure of the graphs is introduced below. The storage structure of graphs, commonly used are " **adjacency matrix** " and " **adjacency table** ".

**1. Adjacency Matrix**

An adjacency matrix is a matrix used to represent a graph. It uses matrices to describe the relationship between vertices in the graph (and the right of arcs or edges).

Assuming that the number of vertices in the graph is n, the adjacency matrix is defined as:

This is explained by the following.

The G1 in the graph is a non-aligned graph and its corresponding adjacency matrix.

The G2 in the graph is a non-aligned graph and its corresponding adjacency matrix.

The adjacency matrix is usually implemented with two arrays: a one-dimensional array to hold vertex information, a two-dimensional array to hold the information of the edge.

The disadvantage of adjacency matrix is that it is more space-consuming.

**2. adjacency table**

adjacency tables are a chain-store representation of graphs. It is an improved "adjacency matrix", its disadvantage is not convenient to determine whether there are two vertices between the edges, but the relative adjacency matrix is more space-saving.

The G1 in the graph is a non-aligned graph and its corresponding adjacency matrix.

The G2 in the graph is a non-aligned graph and its corresponding adjacency matrix.

The theoretical basis of the PHP algorithm "graph"