算法概论(注释版)课后习题8.15

Description

8.15 Show that the following problem is NP-complete.
MAXIMUM COMMON SUBGRAPH
Input: Two graphes G1=(V1,E1) and G2=(V2,E2); a budget b.
Output: Two set of nodes V1‘⊆V1 and V2‘⊆V2 whose deletion leaves at least b nodes in each graph, makes the graphs identical.

Analyse

这个问题的本意就是在两个图里面找一个公共子图,题目对公共子图的描述是,我们对两个图G1和G2,他们分别去掉点集V1‘和V2‘之后,两个图都得到结点数至少为b的子图,且两个子图完全相同。
我们先证明它是个NP问题,因为有最大公共子图,并且已经知道他们的顶点,可在多项式时间内检验是否正确,故是NP 问题。
我们再证明它是个NP完全问题,我们可以设G1=(V,E),G2=(V,Φ),也就是说G1和G2的点集相同,但G2没有边集。若当我们在G1上找到一个大小至少为b的独立子集的时候,那么G1和G2就存在大小至少为b的公共子图了。所以它属于一个NP完全问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
序言 Preface 方框目录 0Prologue(序论) 0.1Booksandalgorithms(书和算法) 0.2EnterFibonacci(斐波那契数列) 0.3Big-Onotation(大O记号) Exercises(习题) 1Algorithmswithnumbers(数的算法) 1.1Basicarithmetic(基本算术) 1.2Modulararithmetic(模运算) 1.3Primalitytesting(素性测试) 1.4Cryptography(密码学) 1.5Universalhashing(全域散列) Exercises(习题) Randomizedalgorithms:avirtualchapter(虚拟章:随机化算法) 2Divide-and-conqueralgorithms(分而治之算法) 2.1Multiplication(乘法) 2.2Recurrencerelations(递归关系) 2.3Mergesort(合并排序) 2.4Medians(中位数) 2.5Matrixmultiplication(矩阵乘法) 2.6ThefastFouriertransform(快速傅里叶变换) Exercises(习题) 3Decompositionsofgraphs(图的分解) 3.1Whygraphs?(图论) 3.2Depth-firstsearchinundirectedgraphs(无向图中的深度优先搜索) 3.3Depth-firstsearchindirectedgraphs(有向图中的深度优先搜索) 3.4Stronglyconnectedcomponents(强连通分量) Exercises(习题)—— 4Pathsingraphs(图的路径) 4.1Distances(距离) 4.2Breadth-firstsearch(广度优先搜索) 4.3Lengthsonedges(边的长度) 4.4Dijkstra’salgorithm(Dijkstra算法) 4.5Priorityqueueimplementations(实现优先队列) 4.6Shortestpathsinthepresenceofnegativeedges(带负权的边的图中的最短路径) 4.7Shortestpathsindags(有向无环图中的最短路径) Exercises(习题) 5Greedyalgorithms(贪婪算法) 5.1Minimumspanningtrees(最小生成树) 5.2Huffmanencoding(赫夫曼编码) 5.3Hornformulas(Horn公式) 5.4Setcover(集合覆盖) Exercises(习题) 6Dynamicprogramming(动态规划) 6.1Shortestpathsindags,revisited(回顾:有向无环图中的最短路径) 6.2Longestincreasingsubsequences(最长 递增子序列) 6.3Editdistance(编辑距离) 6.4Knapsack(背包问题) 6.5Chainmatrixmultiplication(链式矩阵乘法) 6.6Shortestpaths(最短路径) 6.7Independentsetsintrees(树中的独立集) Exercises(习题) 7Linearprogrammingandreductions(线性规划与归约) 7.1Anintroductiontolinearprogramming(线性规划入门) 7.2Flowsinnetworks(网络流) 7.3Bipartitematching(二部图匹配) 7.4Duality(对偶性) 7.5Zero-sumgames(零和游戏) 7.6Thesimplexalgorithm(单纯形算法) 7.7Postscript:circuitevaluation(附录:电路求值) Exercises(习题) 8NP-completeproblems(NP完全问题) 8.1Searchproblems(搜索问题) 8.2NP-completeproblems(NP完全问题) 8.3Thereductions(归约) Exercises(习题) 9CopingwithNP-completeness(处理NP完全问题) 9.1Intelligentexhaustivesearch(智能穷举搜索) 9.2Approximationalgorithms(近似算法) 9.3Localsearchheuristics(局部启发式搜索) Exercises(习题) 10Quantumalgorithms(量子算法) 10.1Qubits,
好,您想要了解如何在Skywalking 8.15本中设置Gateway网关过滤器以将链路信息发送到Skywalking中。下面是一些步骤,供您参考: 1. 首先,请确保您已经安装了Skywalking 8.15,并且已经将其集成到您的应用程序中。 2. 接下来,您需要在Gateway网关中设置过滤器。可以使用Spring Cloud Gateway或Zuul进行设置。这里以Spring Cloud Gateway为例。 3. 在您的Spring Cloud Gateway配置类中,创建一个Bean,用于创建Skywalking过滤器。以下是一个示例代码: ``` @Bean public GlobalFilter customSkywalkingFilter() { return new CustomSkywalkingFilter(); } public class CustomSkywalkingFilter implements GlobalFilter, Ordered { private static final Logger logger = LoggerFactory.getLogger(CustomSkywalkingFilter.class); @Override public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { Span span = ContextManager.createEntrySpan("CustomSkywalkingFilter", new Tag[] {}, exchange.getRequest().getURI().getPath()); try { return chain.filter(exchange).then(Mono.fromRunnable(() -> { if (span != null) { ContextManager.stopSpan(); } })); } catch (Throwable e) { logger.error("CustomSkywalkingFilter catch exception:{}", e.getMessage()); if (span != null) { ContextManager.stopSpan(); } throw e; } } @Override public int getOrder() { return -1; } } ``` 4. 在Skywalking的配置文件中,您需要设置以下属性: ``` collector.backend_service=${skywalking.collector.backend_service} ``` 其中`${skywalking.collector.backend_service}`是您Skywalking后端的地址。 5. 最后,启动您的应用程序,并使用浏览器或其他工具访问您的API网关。您应该可以在Skywalking的UI中看到您的API网关的链路信息。 希望这些步骤可以帮助您在Skywalking 8.15本中设置Gateway网关过滤器以将链路信息发送到Skywalking中。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值