更改

跳到导航 跳到搜索
删除7,660字节 、 2021年6月2日 (三) 17:26
第40行: 第40行:  
强明确树(英语:multitree)是每两个顶点最多被一条路径所连接的有向无环图。等价的说,它是满足以下性质的一个有向无环图:对于图中每个顶点v,从v可达的顶点组成一颗树。[16]
 
强明确树(英语:multitree)是每两个顶点最多被一条路径所连接的有向无环图。等价的说,它是满足以下性质的一个有向无环图:对于图中每个顶点v,从v可达的顶点组成一颗树。[16]
   −
== Computational problems ==
+
=== 计算问题 ===
   −
=== Topological sorting and recognition 拓扑排序和识别 ===
+
=== 拓扑排序和识别 ===
 
  −
Topological sorting is the algorithmic problem of finding a topological ordering of a given DAG. It can be solved in linear time.[16] Kahn's algorithm for topological sorting builds the vertex ordering directly. It maintains a list of vertices that have no incoming edges from other vertices that have not already been included in the partially constructed topological ordering; initially this list consists of the vertices with no incoming edges at all. Then, it repeatedly adds one vertex from this list to the end of the partially constructed topological ordering, and checks whether its neighbors should be added to the list. The algorithm terminates when all vertices have been processed in this way.[17] Alternatively, a topological ordering may be constructed by reversing a postorder numbering of a depth-first search graph traversal.[16]
      
可以用线性时间复杂度的卡恩算法来找到一个有向无环图的拓扑排序。[17]简单来说,开设一个存放结果的列表L,先将入度为零的节点放到L中,因为这些节点没有任何的父节点。将与这些节点相连的边从图中去掉,再寻找图中入度为零的节点。对于新找到的节点来说,他们的父节点已经都在L中了,所以也可以从末端插入L。重复上述操作,直到找不到入度为零的节点。[17] 另外一种构造拓扑排序的算法是将深度优先搜索的后序遍历结果翻转。[16]
 
可以用线性时间复杂度的卡恩算法来找到一个有向无环图的拓扑排序。[17]简单来说,开设一个存放结果的列表L,先将入度为零的节点放到L中,因为这些节点没有任何的父节点。将与这些节点相连的边从图中去掉,再寻找图中入度为零的节点。对于新找到的节点来说,他们的父节点已经都在L中了,所以也可以从末端插入L。重复上述操作,直到找不到入度为零的节点。[17] 另外一种构造拓扑排序的算法是将深度优先搜索的后序遍历结果翻转。[16]
  −
It is also possible to check whether a given directed graph is a DAG in linear time, either by attempting to find a topological ordering and then testing for each edge whether the resulting ordering is valid[18] or alternatively, for some topological sorting algorithms, by verifying that the algorithm successfully orders all the vertices without meeting an error condition.[17]
      
检查一个有向图是否为有向无环图亦可在线性时间内完成。一种方法是先找到一个拓扑排序,然后测试这个排序是否能符合图中每条边所连顶点在排序中应该出现的顺序。[18] 对于卡恩算法在内的部分拓扑排序算法,通过在算法终止时判断是否满足一定条件即可知道图是否有环。[17]如果有环,卡恩算法最终获得的L中节点个数会与图的节点总数不同。
 
检查一个有向图是否为有向无环图亦可在线性时间内完成。一种方法是先找到一个拓扑排序,然后测试这个排序是否能符合图中每条边所连顶点在排序中应该出现的顺序。[18] 对于卡恩算法在内的部分拓扑排序算法,通过在算法终止时判断是否满足一定条件即可知道图是否有环。[17]如果有环,卡恩算法最终获得的L中节点个数会与图的节点总数不同。
   −
=== Construction from cyclic graphs ===
+
=== 从其他图构建 ===
从其他图构建
  −
 
  −
 
  −
Any undirected graph may be made into a DAG by choosing a total order for its vertices and directing every edge from the earlier endpoint in the order to the later endpoint. The resulting orientation of the edges is called an acyclic orientation. Different total orders may lead to the same acyclic orientation, so an -vertex graph can have fewer than  acyclic orientations. The number of acyclic orientations is equal to χ(−1)}}, where  is the chromatic polynomial of the given graph.
      
任意无向图都可以被转化为有向无环图。构造方法是选定一个顶点的全序关系Total order,并将无向图中所有边从全序关系中较前的顶点指向较后的顶点。这种方法是定向Orientation (graph theory)方法中的无环定向acyclic orientation。不同的全序关系可能推出相同的无环定向,因此一个包含n个顶点的图的无环定向数量小于n!。如果定义χ为给定图的色多项式Chromatic polynomial,无环定向数量等于|χ(−1)|。[19]
 
任意无向图都可以被转化为有向无环图。构造方法是选定一个顶点的全序关系Total order,并将无向图中所有边从全序关系中较前的顶点指向较后的顶点。这种方法是定向Orientation (graph theory)方法中的无环定向acyclic orientation。不同的全序关系可能推出相同的无环定向,因此一个包含n个顶点的图的无环定向数量小于n!。如果定义χ为给定图的色多项式Chromatic polynomial,无环定向数量等于|χ(−1)|。[19]
  −
[[File:Graph Condensation.svg|thumb|upright=1.5|The yellow directed acyclic graph is the [[Condensation (graph theory)|condensation]] of the blue directed graph. It is formed by [[Edge contraction|contracting]] each [[strongly connected component]] of the blue graph into a single yellow vertex.]]
  −
  −
Any directed graph may be made into a DAG by removing a feedback vertex set or a feedback arc set, a set of vertices or edges (respectively) that touches all cycles. However, the smallest such set is NP-hard to find. An arbitrary directed graph may also be transformed into a DAG, called its condensation, by contracting each of its strongly connected components into a single supervertex. When the graph is already acyclic, its smallest feedback vertex sets and feedback arc sets are empty, and its condensation is the graph itself.
      
任意有环有向图都可以被转化为有向无环图。只要从图中移除反馈节点集(英语:feedback vertex set)或反馈边集(英语:feedback arc set),即对于图中每个环,至少包括环中一个顶点或边的集合。不过,找到反馈节点或边的最小集合是NP困难问题。[20] 另外一种将有环有向图去环的方法是将每个强连通分量收缩为一个顶点。[22] 对于无环图,它的最小反馈顶点或边集为空集,它的强连通分量则为自身。
 
任意有环有向图都可以被转化为有向无环图。只要从图中移除反馈节点集(英语:feedback vertex set)或反馈边集(英语:feedback arc set),即对于图中每个环,至少包括环中一个顶点或边的集合。不过,找到反馈节点或边的最小集合是NP困难问题。[20] 另外一种将有环有向图去环的方法是将每个强连通分量收缩为一个顶点。[22] 对于无环图,它的最小反馈顶点或边集为空集,它的强连通分量则为自身。
   −
=== Transitive closure and transitive reduction 传递闭包和传递归约===
+
=== 传递闭包和传递归约===
 
  −
The transitive closure of a given DAG, with {{mvar|n}} vertices and {{mvar|m}} edges, may be constructed in time {{math|''O''(''mn'')}} by using either [[breadth-first search]] or [[depth-first search]] to test reachability from each vertex.<ref>{{harvtxt|Skiena|2009}}, p. 495.</ref> Alternatively, it can be solved in time {{math|''O''(''n''<sup>''ω''</sup>)}} where {{math|''ω''&nbsp;<&nbsp;2.373}} is the [[Computational complexity of matrix multiplication#Matrix multiplication exponent|exponent for matrix multiplication algorithms]]; this is a theoretical improvement over the {{math|''O''(''mn'')}} bound for [[dense graph]]s.<ref>{{harvtxt|Skiena|2009}}, p. 496.</ref>
  −
 
  −
The transitive closure of a given DAG, with  vertices and  edges, may be constructed in time  by using either breadth-first search or depth-first search to test reachability from each vertex. Alternatively, it can be solved in time  where  is the exponent for matrix multiplication algorithms; this is a theoretical improvement over the  bound for dense graphs.
  −
 
   
有向无环图的传递闭包可以通过广度优先搜索或深度优先搜索对每个节点测试可达性来构建。算法对于一个有着n个顶点和m条边的有向无环图的复杂度为O(mn)。[22]也可以使用矩阵乘法算法(英语:matrix multiplication algorithm)中最快的Coppersmith–Winograd算法(英语:Coppersmith–Winograd algorithm),其复杂度为O(n2.3728639)。这个算法理论上在稠密图(英语:dense graph)中快过O(mn)。[23]
 
有向无环图的传递闭包可以通过广度优先搜索或深度优先搜索对每个节点测试可达性来构建。算法对于一个有着n个顶点和m条边的有向无环图的复杂度为O(mn)。[22]也可以使用矩阵乘法算法(英语:matrix multiplication algorithm)中最快的Coppersmith–Winograd算法(英语:Coppersmith–Winograd algorithm),其复杂度为O(n2.3728639)。这个算法理论上在稠密图(英语:dense graph)中快过O(mn)。[23]
  −
  −
In all of these transitive closure algorithms, it is possible to distinguish pairs of vertices that are reachable by at least one path of length two or more from pairs that can only be connected by a length-one path. The transitive reduction consists of the edges that form length-one paths that are the only paths connecting their endpoints. Therefore, the transitive reduction can be constructed in the same asymptotic time bounds as the transitive closure.<ref>{{harvtxt|Bang-Jensen|Gutin|2008}}, p. 38.</ref>
  −
  −
In all of these transitive closure algorithms, it is possible to distinguish pairs of vertices that are reachable by at least one path of length two or more from pairs that can only be connected by a length-one path. The transitive reduction consists of the edges that form length-one paths that are the only paths connecting their endpoints. Therefore, the transitive reduction can be constructed in the same asymptotic time bounds as the transitive closure.
      
不论在哪种传递闭包算法中,那些被一条长度至少为2的路径所连接的顶点对,都可以和只有一条长度为1的路径所连接的顶点对区分开。由于传递归约包含后者,传递归约可以在和传递闭包相同的渐进时间复杂度(英语:Asymptotic computational complexity)中被构建。[25]
 
不论在哪种传递闭包算法中,那些被一条长度至少为2的路径所连接的顶点对,都可以和只有一条长度为1的路径所连接的顶点对区分开。由于传递归约包含后者,传递归约可以在和传递闭包相同的渐进时间复杂度(英语:Asymptotic computational complexity)中被构建。[25]
   −
=== Closure problem 闭包问题 ===
+
=== 闭包问题 ===
The [[closure problem]] takes as input a vertex-weighted directed acyclic graph and seeks the minimum (or maximum) weight of a closure – a set of vertices ''C'', such that no edges leave ''C''. The problem may be formulated for directed graphs without the assumption of acyclicity, but with no greater generality, because in this case it is equivalent to the same problem on the condensation of the graph. It may be solved in polynomial time using a reduction to the [[maximum flow problem]].<ref>{{citation | last = Picard | first = Jean-Claude | doi = 10.1287/mnsc.22.11.1268 | issue = 11
  −
| journal = [[Management Science (journal)|Management Science]] | mr = 0403596 | pages = 1268–1272 | title = Maximal closure of a graph and applications to combinatorial problems | volume = 22
  −
| year = 1976}}.</ref>
  −
 
  −
The closure problem takes as input a vertex-weighted directed acyclic graph and seeks the minimum (or maximum) weight of a closure – a set of vertices C, such that no edges leave C. The problem may be formulated for directed graphs without the assumption of acyclicity, but with no greater generality, because in this case it is equivalent to the same problem on the condensation of the graph. It may be solved in polynomial time using a reduction to the maximum flow problem.
      
闭包是一个图中没有出边的顶点子集,即不存在从子集中顶点指向子集外顶点的边。闭包问题(英语:closure problem)是则是找到带权图中使得权之和最大或最小的子集。闭包问题可以看作最大流问题的简化版,在多项式时间内被解决。实际上,是否有环对于找到闭包没有影响。[26]
 
闭包是一个图中没有出边的顶点子集,即不存在从子集中顶点指向子集外顶点的边。闭包问题(英语:closure problem)是则是找到带权图中使得权之和最大或最小的子集。闭包问题可以看作最大流问题的简化版,在多项式时间内被解决。实际上,是否有环对于找到闭包没有影响。[26]
   −
=== Path algorithms 最短或最长路径问题 ===
+
=== 最短或最长路径问题 ===
Some algorithms become simpler when used on DAGs instead of general graphs, based on the principle of topological ordering. For example, it is possible to find [[shortest path]]s and [[longest path problem|longest paths]] from a given starting vertex in DAGs in linear time by [[Topological sorting#Application to shortest path finding|processing the vertices in a topological order]], and calculating the path length for each vertex to be the minimum or maximum length obtained via any of its incoming edges.<ref>Cormen et al. 2001, Section 24.2, Single-source shortest paths in directed acyclic graphs, pp. 592–595.</ref> In contrast, for arbitrary graphs the shortest path may require slower algorithms such as [[Dijkstra's algorithm]] or the [[Bellman–Ford algorithm]],<ref>Cormen et al. 2001, Sections 24.1, The Bellman–Ford algorithm, pp. 588–592, and 24.3, Dijkstra's algorithm, pp. 595–601.</ref> and longest paths in arbitrary graphs are [[NP-hard]] to find.<ref>Cormen et al. 2001, p. 966.</ref>
  −
 
  −
Some algorithms become simpler when used on DAGs instead of general graphs, based on the principle of topological ordering. For example, it is possible to find shortest paths and longest paths from a given starting vertex in DAGs in linear time by processing the vertices in a topological order, and calculating the path length for each vertex to be the minimum or maximum length obtained via any of its incoming edges. In contrast, for arbitrary graphs the shortest path may require slower algorithms such as Dijkstra's algorithm or the Bellman–Ford algorithm, and longest paths in arbitrary graphs are NP-hard to find.
      
基于拓扑排序的性质,有向无环图的最短路问题和最长路径问题可以在线性时间内解决。将顶点拓扑排序后,从前到后遍历每一个顶点,对于遍历到的顶点,更新其所有出边所到达顶点的长度值。如果求最短路,则在本边是更短路径的一部分时更新。求最长路则反之。[27]对于非有向无环图,最短路需要用复杂度为
 
基于拓扑排序的性质,有向无环图的最短路问题和最长路径问题可以在线性时间内解决。将顶点拓扑排序后,从前到后遍历每一个顶点,对于遍历到的顶点,更新其所有出边所到达顶点的长度值。如果求最短路,则在本边是更短路径的一部分时更新。求最长路则反之。[27]对于非有向无环图,最短路需要用复杂度为
387

个编辑

导航菜单