is_directed_acyclic_graph¶
- is_directed_acyclic_graph(G)[source]¶
Returns True if the graph
G
is a directed acyclic graph (DAG) or False if not.- Parameters
- GNetworkX graph
- Returns
- bool
True if
G
is a DAG, False otherwise
See also
Examples
Undirected graph:
>>> G = nx.Graph([(1, 2), (2, 3)]) >>> nx.is_directed_acyclic_graph(G) False
Directed graph with cycle:
>>> G = nx.DiGraph([(1, 2), (2, 3), (3, 1)]) >>> nx.is_directed_acyclic_graph(G) False
Directed acyclic graph:
>>> G = nx.DiGraph([(1, 2), (2, 3)]) >>> nx.is_directed_acyclic_graph(G) True