数据结构之图-无权图的最小生成树(7)

本文讨论了无权图的最小生成树问题,指出MST是指连接所有顶点的边数最少的树,其边数等于顶点数减一。通过深度优先搜索(DFS)遍历图得到的路径可以构成一棵MST,并提供了Java实现。
摘要由CSDN通过智能技术生成

1 Unweighted Graphs 

For unweighted Graphs, a minimum  spanning tree(MST) means that a graph with minimum number of edges to connect all the vertices.

the number of edges E in a minimum spanning tree is always one less than the number of vertices V: E = V – 1.

The path of the DFS(depth-first search) through the graph must be a minimum spanning tree.


1.1 Java implement 

   public void mst()  // minimum spanning tree (depth first)
      {                                  // start at 0
      vertexList[0].wasVisited = true;   // mark it
      theStack.push(0);                  // push it

      while( !theStack.isEmpty() )       // until stack emp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值