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

Speed improvements for function transitiveclosure! #870

Merged
merged 2 commits into from
Apr 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/digraph/transitivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,9 @@ This version of the function modifies the original graph.
function transitiveclosure! end
@traitfn function transitiveclosure!(g::::IsDirected, selflooped=false)
for k in vertices(g)
for i in vertices(g)
i == k && continue
for j in vertices(g)
j == k && continue
if (has_edge(g, i, k) && has_edge(g, k, j))
if (i != j || selflooped)
add_edge!(g, i, j)
end
end
end
for i in inneighbors(g, k), j in outneighbors(g, k)
((!selflooped && i == j) || i == k || j == k) && continue
add_edge!(g, i, j)
end
end
return g
Expand Down