MATLAB 帮助中心
确定图是否为无环
tf = isdag(G)
如果 G 是有向无环图,则 tf = isdag(G) 返回逻辑值 1 (true);否则返回逻辑值 0 (false)。
G
1
true
0
false
示例
全部折叠
创建和绘制有向图,然后检验该图以确定它是否无环。
s = [1 1 2 2 3 3 4 4 4 5]; t = [2 3 4 5 6 7 8 9 10 4]; G = digraph(s,t)
G = digraph with properties: Edges: [10×1 table] Nodes: [10×0 table]
plot(G)
tf = logical 1
digraph
输入图,指定为 digraph 对象。使用 digraph 创建有向图对象。
示例: G = digraph([1 2],[2 3])
G = digraph([1 2],[2 3])
不包含任何循环的有向图是无环的。就是说,图中不存在从任何节点开始以循环方式回到该起始节点的边序列。因此,有向无环图不包含任何自环。
在 R2015b 中推出
toposort | reordernodes | digraph | hascycles
toposort
reordernodes
hascycles
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处