2019东北赛补题之(E. Minimum Spanning Tree)贪心(伪最小生成树)

该博客讨论了如何在给定一棵简单无向加权树G的情况下,找到其线图L(G)的最小生成树。它指出,对于每个入度大于2的节点,只需选择du-1条伪边作为贡献。通过贪心策略,选取度数为2以上的节点的(degree-1)条相邻边,可以构建MST(L(G)),并提供了相关算法思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

E. Minimum Spanning Tree

time limit per test

2.0 s

memory limit per test

512 MB

input

standard input

output

standard output

In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph GG is another simple undirected weighted graph L(G)L(G) that represents the adjacency between every two edges in GG.

Precisely speaking, for an undirected weighted graph GG without loops or multiple edges, its line graph L(G)L(G) is a graph such that:

  • Each vertex of L(G)L(G) represents an edge of GG.
  • Two vertices of L(G)L(G) are adjacent if and only if their corresponding edges share a common endpoint in GG, and the weight of such edge between this two vertices is the sum of their corresponding edges' weight.

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值