图结构基础及通用代码实现
In a Nutshell
A graph structure is an extension of the multi-way tree structure.
In a tree structure, a parent node can only point to its child nodes, and there are no links from child nodes to parent nodes or between sibling nodes. In contrast, a graph has fewer restrictions, allowing nodes to point to each other, forming a more complex network structure.
Because graph structures can abstract more complex problems, they have led to the development of more sophisticated graph algorithms. Some classic examples include the Bipartite Graph Algorithm, Topological Sorting, Shortest Path Algorithm, and Minimum Spanning Tree Algorithm, all of which will be introduced later.
This article mainly introduces the basic concepts of graphs and how to implement them in code.