This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Determine if graph is acyclic


tf = isdag(G)



tf = isdag(G) returns logical 1 (true) if G is a directed acyclic graph; otherwise, it returns logical 0 (false).


collapse all

Create and plot a directed graph, and then test the graph to determine if it is acyclic.

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: [10x1 table]
    Nodes: [10x0 table]


tf = isdag(G)
tf = logical

Input Arguments

collapse all

Input graph, specified as a digraph object. Use digraph to create a directed graph object.

Example: G = digraph([1 2],[2 3])

More About

collapse all

Directed Acyclic Graph (DAG)

A directed graph is acyclic if it contains no cycles. That is, starting at any node in the graph, no sequence of edges exists that can be followed to loop back to that starting node. As a result, directed acyclic graphs do not contain any self-loops.

Introduced in R2015b