我可以适用于本DAG哪种算法? [英] What algorithm can I apply to this DAG?

查看:161
本文介绍了我可以适用于本DAG哪种算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DAG重新presenting属性的列表。这些属性是这样的,如果A> B,则有向边到b。它是可传递的一样,所以,如果A> B和B> C,则有向边至c

I have a DAG representing a list of properties. These properties are such that if a>b, then a has a directed edge to b. It is transitive as well, so that if a>b and b>c, then a has a directed edge to c.

然而,定向的边缘从a到c是多余的,因为一个具有定向的边缘到b和b有一个定向的边缘至c。我怎样才能修剪所有这些多余的边?我想用最小生成树算法,但我真的不知道什么是合适的算法在这种情况下适用

However, the directed edge from a to c is superfluous because a has a directed edge to b and b has a directed edge to c. How can I prune all these superfluous edges? I was thinking of using a minimum spanning tree algorithm, but I'm not really sure what is the appropriate algorithm to apply in this situation

我想我可以做的每个节点及其所有出边深度优先搜索和比较,如果能达到一定的节点,而无需使用特定的边缘,但这似乎可怕的低效和缓慢的。

I suppose I could do a depth first search from each node and all its outgoing edges and compare if it can reach certain nodes without using certain edges, but this seems horribly inefficient and slow.

在时,输出将是一个顺序,它与图相一致的所有节点的线性列表。因此,如果一个具有三个向边到b,c和d。 b和c还各自有一个向边至d,输出可以是abcd或者ACBD

After the algorithm is complete, the output would be a linear list of all the nodes in an order that is consistent with the graph. So if a has three directed edges to b,c, and d. b and c also each of which has a directed edge to d, the output could be either abcd or acbd.

推荐答案

这就是所谓的传递减少的问题。从形式上来讲,你正在寻找一个最小(最少边)向图中,传递闭包,其中等于输入图的传递闭包。 (以上维基百科的链接,该图明确。)

This is called the transitive reduction problem. Formally speaking, you are looking for a minimal (fewest edges) directed graph, the transitive closure of which is equal to the transitive closure of the input graph. (The diagram on the above Wikipedia link makes it clear.)

显然有用于解决该问题,即采用相同的时间作为用于生产传递闭包(添加移除其中传递链接,而不是如比较常见的逆问题)存在一种有效的算法,但是在<一href="http://scitation.aip.org/getabs/servlet/GetabsServlet?prog=normal&id=SMJCAT000001000002000131000001&idtype=cvips&gifs=yes"相对=nofollow>链接到1972年的论文阿霍,Garey和乌尔曼的花费$ 25下载和一些快速谷歌搜索不转了任何好的说明。

Apparently there exists an efficient algorithm for solving this problem that takes the same time as for producing a transitive closure (i.e. the more common inverse problem of adding transitive links instead of removing them), however the link to the 1972 paper by Aho, Garey, and Ullman costs $25 to download, and some quick googling didn't turn up any nice descriptions.

编辑:斯科特棉花 graphlib 包含一个<一个href="https://$c$c.google.com/p/stixar-graphlib/source/browse/trunk/src/java/stixar/graph/conn/Transitivity.java"相对=nofollow> Java实现!:此Java库看起来是非常良好的组织。

Scott Cotton's graphlib contains a Java implementation! This Java library looks to be very well organised.

这篇关于我可以适用于本DAG哪种算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆