Vertex Cover

本文介绍了图论中的Vertex Cover问题,青蛙有一张包含n个顶点和m条边的图,目标是找到最少数量的染色顶点,使得每条边至少连接一个染色顶点。输入包括多个测试案例,每个案例包含n和m的值,以及边的详细信息。输出为每个测试案例的最小染色顶点数。
摘要由CSDN通过智能技术生成

frog has a graph with n vertices v(1),v(2),…,v(n) and m edges (v(a1),v(b1)),(v(a2),v(b2)),…,(v(am),v(bm))

.

She would like to color some vertices so that each edge has at least one colored vertex.

Find the minimum number of colored vertices.

Input

The input consists of multiple tests. For each test:

The first line contains 2

integers n,m (2≤n≤500,1≤m≤n(n−1)2). Each of the following m lines contains 2 integers ai,bi (1≤ai,bi≤n,ai≠bi,min{ai,bi}≤30

)

Output

For each test, write 1

integer which denotes the minimum number of colored vertices.

Sample Input

    3 2
    1 2
    1 3
    6 5
    1 2
    1 3
    1 4
    2 5
    2 6

Sample Output

    1
    2
#include <bits/stdc++.h>
using na
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值