For graphs, the adjacency matrix is a good graph storage structure, but we also find that for graphs with fewer edges relative to vertices, this structure has a great waste of storage space. So we consider another type of storage structure: adjacency table (adjacency list), that is, the combination of array and linked list of storage methods.
The method of dealing with the adjacency table is this.
1, the vertex in the graph is stored in a one-dimensional array, in addition, for the vertex array, each data element also needs to store a pointer to the first adjacency point to facilitate the lookup of the vertex's edge information.
2, the graph of each vertex VI of all adjacent points constitute a linear table, because the number of adjacent points is uncertain, so with a single chain table storage, the non-map is called Vertex vi edge table, there is to the graph called Vertex VI as the arc tail of the edge table.
For example, the graph 7-4-6 is an adjacency table structure of a non direction graph.
If there is a direction graph, the structure of the adjacency table is similar, such as Figure 7-4-7, it is easy to get the degree of each vertex by the vertex as the arc tail, and the table with the vertex as the arc head is easy to get the vertex's entry degree, namely the inverse adjacency table.
For a network map with weights, you can add a weight data field to the definition of the side table node and store the weight information, as shown in Figure 7-4-8.