(1) Dijkstra-Prim algorithm and Kruskal algorithm
The basic idea of the Dijkstra-Prim algorithm: All nodes are divided into two groups, one is the selected selected_node (list type), and the other is candidate_node. First, take any node and add it to selected_node, then traverse the head node in selected_node, and the tail node in candidate_node , select the edge with the smallest weight among the edges that meet this condition, and add it to the minimum spanning tree. The tail node of the selected edge is added to selected_node, and deleted from candidate_node. Until there is no candidate node in candidate_node (this loop condition requires that all nodes have edge connections, that is, the number of edges must be greater than or equal to the number of nodes -1, this condition must be added before the loop starts, otherwise there may be nodes that are always in the candidate, resulting in infinite loop).
The basic idea of the Kruskal algorithm: first sort the edges from small to large in weight, and select the edge with the smallest weight first. If the two nodes of the edge are different components, add it to the minimum spanning tree, otherwise calculate the next edge, until All edges are traversed.
Dijkstra-Prim algorithm:
Kruskal's algorithm:
mark answer:
(2) Graph search algorithm
answer:
1) Apply cost-based unified search, the order in which state nodes are expanded is: start, B, A, D, C, Goal. The returned path is: Start-AD-Goal.
2) Using the A* graph search algorithm, the order in which states are expanded is: Start, B, A, D, C, Goal. The returned path is: Start-AD-Goal.
The expansion sequence is as shown in the figure: