算法作业 NP-complete problems 8.22

本文探讨了反馈弧集问题及其与顶点覆盖问题之间的联系。反馈弧集问题要求在一个有向图中找到最小数量的边移除,使得图变得无环。文章通过构造一种特殊的有向图实例,证明了这两个问题间的等价性,并展示了如何从一个问题的解决方案推导出另一个问题的解。

8.22 

In task scheduling,it is common to use a graph representation with a node for each task and  a directed edge from task i to task j if i is a precondition for j.This directed graph depicts the precedence constraints in the scheduling problem.Clearly,a schedule is possible if and only if the graph is acyclic;if it isn't,we'd like to identify the smallest number of constraints that must be dropped so as to make it acyclic.

Given a directed graph G=(V,E),a subset E'≤E is called a feedback arc set if the removal of edges E' renders G acyclic.

FEEDBACK ARC SET(FAS):Given a directed graph G=(V,E) and a budget b,find a feedback arc set of <=b edges,if one exists.

(a)Show that FAS is in NP

FAScan be shown to be NP-complete by a reduction from VERTEX COVER.Given an instance (G,b) of VERTEX COVER,where G is an undiected graph and we want a vertex cover of size <=b,we construct a instance (G',b) of FAS as follows.If G=(V,E) has n vertices v1,...,vn,then make G'=(V',E') a directed graph with 2n vertices w1,w1',...,wn.wn',and n+2|E|(directed) edges:

1.(wi,wi') for all i=1,2,...,n.

2.(wi',wj) and (wj',wi) for every (vi,vj)∈E.

(b)Show that if G containsa vertex cover of size b,then G' contains a feedback arc set of size b.

(c)Show that if G' contains a feedback arc set of size b,then G contains a vertex cover of size (at most) b.(Hint:Given a feedback arc set of size b in G',you may need to first modify it slightly to obtain another one which is of a more convenient form,but is of the same size or smaller.Then,argue that G must contain a vertex cover of the same size as the modified feedback arc set.)



(a)  显然FAS是可在多项式时间内验证的,因此属于NP。
(b)  设G的一个大小为b的顶点覆盖为C,对于任意顶点vi∈C ,设其在 ' G中相对应的顶点为wi和wi ',则将边(wi,wi'),添加到 E'。对C中的每个顶点都这样处
理后,所得到的边集E'即是G'的一个大小为b的feedback arc set。因为对于顶点wi和wi',当去掉边(wi,wi')后,所有与wi相连的边都不可能位于任何一个
环中,因为wi不存在出边,同样,所有与wi'相连的边也不可能位于任何一个环中,因为wi'不存在入边。
(c)  对于G中的任意一条边(vi,vj),设其在G'中相对应的顶点为wi,wi',wj,wj',相对应的边为(wi,wi'),(wj,wj'),(wi',wj),(wj',wi). 若E'是G'的一个大小为b的feedback arc set,显然,在这四条边中至少有一条边e属于E',否则就会形成环,而边e必然有个端点属于{wi,wj}.若wi是e的端点,则将vi加入到C,否则将vj加入到C。容易看出,在经过上述处理后,C即是G的一个大小不超过b的顶点覆盖。




### 安装 Coreutils-8.22 的方法 要安装 `Coreutils-8.22`,可以按照以下方式操作。以下是基于 CentOS 或其他 RPM 基础系统的具体说明。 #### 1. 获取源码包 首先需要下载 `coreutils-8.22` 的源码包文件。可以通过官方镜像站点获取该版本的 `.src.rpm` 文件[^2]: ```bash wget https://vault.centos.org/7.9.2009/os/Source/SPackages/coreutils-8.22-24.el7.src.rpm ``` 此命令会将核心工具集的源代码压缩包下载到当前目录下。 #### 2. 准备开发环境 为了编译并构建 `coreutils-8.22`,需先安装必要的依赖项和工具链。这些工具通常包括但不限于 `automake`, `autoconf`, `intltool`, `libtool`, 和 C++ 编译器等[^3]。执行如下命令来完成所需软件包的安装: ```bash yum install -y automake autoconf intltool libtool gcc-c++ yum install -y unzip wget bison gperf texinfo ``` 以上步骤确保了系统具备足够的资源用于后续的配置与编译过程。 #### 3. 构建 RPM 包 一旦获得源码以及准备好所需的构建工具之后,则可继续创建二进制形式的 RPM 软件包。这一步骤涉及解压已有的 SRPM 并重新打包成适合目标架构使用的最终产物。具体流程如下所示: ```bash rpm -ivh coreutils-8.22-24.el7.src.rpm # 安装源码RPM至默认位置 /root/rpmbuild/ cd /root/rpmbuild/SPECS/ rpmbuild -ba coreutils.spec # 使用 spec 文件生成新的 RPMs ``` 上述指令中的 `-ba` 参数指示 rpmbuild 同时处理所有的体系结构选项;如果仅针对特定平台定制化生产的话也可以替换为更精确的形式比如 `-bb`(Build Binary)或者 `-bi`(Build Initial)等等。 #### 4. 部署新构建好的 RPM 当成功制作完毕后的新版 Coreutils 就会被放置于 `/root/rpmbuild/RPMS/x86_64/` 目录之下(假设主机运行的是 X86_64 类型处理器),此时只需简单运用 rpm 工具即可实现部署: ```bash rpm -Uvh /root/rpmbuild/RPMS/x86_64/coreutils*.rpm # 升级现有程序实例 ``` 至此即完成了整个从零开始的手动升级 GNU Core Utilities 到指定版本号的操作全流程[^4]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值