Min Spanning Tree: E = V-1
The minimum spanning tree of a no-Permission graph does not need to care about the edge length, but needs to find the minimum number of edges.
The Minimum Spanning Tree is almost the same as the search algorithm, and can also be used for deep and breadth-first searches.
The DFS algorithm only accesses all vertices once and never accesses the same vertex twice. When you see an edge
It is about to reach an accessed vertex, so it will not go through this edge. Therefore, the DFS algorithm must go through the path of the entire graph.
Is the Minimum Spanning Tree.
The DFS algorithm is improved, but the current vertex is output in else.
Public void MST () {stack <integer> stack = new stack <integer> (); // access the first vertex varr [0]. isvisited = true; // stack. push (0); While (! Stack. isempty () {int currv = stack. peek (); int v = getunvisitedvertex (currv); If (V =-1) {stack. pop ();} else {varr [v]. isvisited = true; stack. push (V); disvertex (currv); // display the current vertex disvertex (V); // display adjacent contacts, the edges composed of these two vertices are the edges of the MST} reset ();}