Previously, I used the adjacent matrix to store graph information. However, I found that the space provided by some questions was not enough to open a two-dimensional array, so I could no longer use the adjacent matrix for storage, then I learned how to use the link list.
The adjacent linked list first has a struct used to store the information of the entire graph. This struct contains some basic information about the graph, such as the number of vertices and the number of edges, there is also an array that stores all vertex information. Of course, this array is the structure array that will be mentioned later to store vertex information. Its Array range is the range of vertex numbers in the graph.
There is also a struct that stores vertex information. This struct contains basic vertex information, such as vertex numbers. There are also two linked list headers pointing to edge nodes that will be mentioned next, the two linked lists are the output edge linked list and the inbound edge linked list respectively.
As for the edge linked list node structure, it is used to create an edge linked list and an inbound edge linked list. The same structure is used to create a linked list, which is divided into two parts. One is a data block, it is used to store the basic information of a node, and the other is a pointer to the next edge node.
Here we will describe the output-edge linked list and the inbound-edge linked list.
If the output edge linked list of node a is used, it indicates that the linked list stores the information of those nodes at the end of the edge starting from node a, and their order only indicates the order of reading information.
If we talk about the edge linked list of node a, it means that the linked list stores the information of those starting points whose end points are node a, and their order only indicates the order of reading information.
If you use a linked list to store Graph Information, you need to create or delete a linked list. These operations involve linked lists. It is easier to understand the structure hierarchy of the adjacent linked list.