Min Spanning tree: E = V-1
The minimum spanning tree of the unauthorized graph does not need to care about the length of the edge, but to find the least number of edges.
The minimum spanning tree is almost identical to the search algorithm and can also be given depth-first search and breadth-first search.
The DFS algorithm accesses all vertices, but accesses only once and never accesses the same vertex two times. When you see a certain edge
is going to reach an already visited vertex, it will not go this side. So the DFS algorithm passes through the path of the whole diagram must
Is the minimum spanning tree.
The improvement to the DFS algorithm is to simply output the current vertex in the Else
public void MST () {
stack<integer> Stack = new stack<integer> ();
Start accessing the first vertex
varr[0].isvisited = true;
Into the stack
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); Displays the current vertex
Disvertex (v); Shows the adjacency point, the edge of the two vertices is the side of the MST
}
Reset ();
}