Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
short circuit is_connected (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbromberger authored Mar 20, 2017
1 parent 4ce09df commit 9dd2b87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/connectivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ end
Returns `true` if `g` is connected.
For DiGraphs, this is equivalent to a test of weak connectivity.
"""
is_connected(g::Graph) = length(connected_components(g)) == 1
is_connected(g::DiGraph) = is_weakly_connected(g)
is_connected(g::Graph) = ne(g)+1 >= nv(g) && length(connected_components(g)) == 1
is_connected(g::DiGraph) = ne(g)+1 >= nv(g) && is_weakly_connected(g)

"""Returns connected components of the undirected graph of `g`."""
weakly_connected_components(g::DiGraph) = connected_components(Graph(g))
Expand Down

0 comments on commit 9dd2b87

Please sign in to comment.