- shows edges abbccdand debut edges acceedand db would do just as well the arithmetically inclined will note that the number of edges in minimum spanning tree is always one less than the number of vertices ve= - remember that we're not worried here about the length of the edges we're not trying to find minimum physical lengthjust the minimum number of edges (this will change when we talk about weighted graphs in the next the algorithm for creating the minimum spanning tree is almost identical to that used for searching it can be based on either the depth-first search or the breadth-first search in our example we'll use the depth-first-search it turns out that by executing the depth-first search and recording the edges you've traveled to make the searchyou automatically create minimum spanning tree the only difference between the minimum spanning tree method mst()which we'll see in momentand the depth-first search method dfs()which we saw earlieris that mst(must somehow record the edges traveled graphn workshop applet repeatedly clicking the tree button in the graphn workshop algorithm will create minimum spanning tree for any graph you create try it out with various graphs you'll see that the algorithm follows the same steps as when using the dfs button to do search when using treehoweverthe appropriate edge is darkened when the algorithm assigns it to the minimum spanning tree when it' finishedthe applet removes all the non-darkened linesleaving only the minimum spanning tree final button press restores the original graphin case you want to use it again java code for the minimum spanning tree here' the code for the mst(methodwhile!thestack isempty(/until stack empty /get stack top int currentvertex thestack peek()/get next unvisited neighbor int getadjunvisitedvertex(currentvertex)if( =- /if no more neighbors thestack pop()/pop it away else /got neighbor vertexlist[vwasvisited true/mark it thestack push( )/push it /display edge displayvertex(currentvertex)/from currentv displayvertex( )/to system out print(")/end while(stack not empty/stack is emptyso we're done