Rosalind第32题:Completing a Tree

Problem

Figure 2. A labeled tree with 6 vertices and 5 edges.

An undirected graph is connected if there is a path connecting any two nodes. A tree is a connected (undirected) graph containing no cycles; this definition forces the tree to have a branching structure organized around a central core of nodes, just like its living counterpart. See Figure 2.

We have already grown familiar with trees in “Mendel's First Law”, where we introduced the probability tree diagram to visualize the outcomes of a random variable.

In the creation of a phylogeny, taxa are encoded by the tree's leaves, or nodes having degree 1. A node of a tree having degree larger than 1 is called an internal node.

Given: A positive integer  () and an adjacency list corresponding to a graph on  nodes that contains no cycles.

Return: The minimum number of edges that can be added to the graph to produce a tree.

无向连接,如果有一个路径连接的任意两个节点。甲是不包含一个连接(无向)图个循环; 此定义迫使树具有围绕节点的中心核心组织的分支结构,就像其活动副本一样。参见图2

我们已经长大熟悉树“孟德尔第一定律”,在这里我们引入了概率树图 以可视化的结果一的随机变量

在系统发育的创建中,分类单元由树的叶子或具有1的节点编码。树的度大于1的节点称为内部节点

给定:与不包含循环的节点上的图相对应的正整数()和邻接表

返回值:可以添加到图中以生成树的最小数。

Sample Dataset

10
1 2
2 8
4 10
5 9
6 10
7 9

Sample Output

3
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值