-
Notifications
You must be signed in to change notification settings - Fork 183
Added function transitivereduction #877
Added function transitivereduction #877
Conversation
docstring formatting
Codecov Report
@@ Coverage Diff @@
## master #877 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 59 59
Lines 2989 3027 +38
=====================================
+ Hits 2989 3027 +38 |
test/digraph/transitivity.jl
Outdated
add_edge!(barbell_graph, 1,5); | ||
|
||
# transitive reduction of a the nullgraph is again a nullgraph | ||
@test nullgraph == transitivereduction(nullgraph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be tested on graphs of varying eltype
s: that is, see the testgraphs
/ testdigraphs
functions:
for g in testgraphs(barbell_graph)
... do tests
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea that we use testdigraphs for all testcases or should I just do this for this barbell_graph? I might have to replace that test anyway as I have to come up with another example that covers all lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, we prefer testgraphs / testdigraphs for all test cases, inside the loop.
I changed the test now and fixed some errors. It should cover all code lines now, the reason if did not before was that I created an a graph with no edges instead of a path in my tests. |
This looks good. The only nitpicky comment I have is that your indents don't line up consistently, but that can be fixed after the fact (and with a good linter - try vscode w/ the Julia plugin if you have a chance!) cc @jpfairbanks for a sanity check. Thanks, @simonschoelly! |
pinging @jpfairbanks for a quick review, please? |
Thanks!! |
Added function transitivereduction (sbromberger#877)
* removed flow algorithms (sbromberger#815) * fixes sbromberger#820, plus tests (sbromberger#821) * change show() for empty graphs (ref JuliaGraphs/MetaGraphs.jl#20 (comment)) (sbromberger#822) * Pull request clique_percolation.jl (sbromberger#826) clique percolation is a method of uncovering the overlapping community structure of complex networks in nature and society * add src/community/clique_percolation.jl * tests in file test/community/clique_percolation.jl * cites the original clique percolation paper * for undirected graphs only using traitfn * in_ / out_ -> in / out (sbromberger#830) * (in,out)_neighbors -> (in,out)neighbors * all_neighbors -> allneighbors * Pull request clique_percolation.jl (sbromberger#826) clique percolation is a method of uncovering the overlapping community structure of complex networks in nature and society * add src/community/clique_percolation.jl * tests in file test/community/clique_percolation.jl * cites the original clique percolation paper * for undirected graphs only using traitfn * revert allneighbors * expected_degree_graph (Chung-Lu model) (sbromberger#832) * Expected degree random graph generator implemented, including tests * algorithm corrected * Missing seed corrected in expected_degree_graph * expected_degree_graph! implemented * Added return in function, comment with references removed, references in docs added (expected_degree_graph) * Update randgraphs.jl minor doc update * Update randgraphs.jl * Fixing problems with MST Kruskal's on SimpleWeightedGraphs (sbromberger#835) * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update prim.jl * reverting changes * Revert "reverting changes" This reverts commit ac1760b. * Revert "Update prim.jl" This reverts commit 677f6fa. * Revert "Update kruskal.jl" This reverts commit a0e9c47. * Revert "Update prim.jl" This reverts commit 793bac4. * Revert "Update kruskal.jl" This reverts commit 6114e16. * Revert "Update prim.jl" This reverts commit 551f1e6. * Revert "Update kruskal.jl" This reverts commit 941005e. * Revert "Update kruskal.jl" This reverts commit a404514. * Revert "Update prim.jl" This reverts commit 2d43a60. * Revert "Update kruskal.jl" This reverts commit 4577920. * fix problems with SimpleWeightedGraphs * fix problems with SimpleWeightedGraphs * fix problems with SimpleWeightedGraphs * bipartite_map on 2-order graphs fixed. Added proper tests. Fixed test connected to bipartite_map (sbromberger#836) * Correct pre-allocation of memory in Prim's MST (sbromberger#839) * Improve Kruskal's MST by optimizing Union-Find (sbromberger#843) * add missing backtick (sbromberger#846) * Add greedy_color for Graph Coloring (sbromberger#844) * Add greedy_color for Graph Coloring * Improve Kruskal's MST by optimizing Union-Find (sbromberger#843) * Update README.md * Update README.md * first cut at 0.7 compatibility (sbromberger#848) * using LightGraphs does not error * Switch to LinearAlgebra and SparseArrays std libs * Fix most of linalg tests * Add SharedArrays for distance tests to compile * Add Random and Markdown to stdlibs used * Fix connectivity tests * IntSet -> BitSet * Add DelimitedFiles stdlib for readcsv * Fix failing test * first cut * Use mauro/SimpleTraits.jl/m3/where-fns in tests * Fix SimpleTraits checkout (sbromberger#851) * Move up SimpleTraits checkout (sbromberger#852) * Update runtests.jl * Update REQUIRE * Update REQUIRE * femtocleaner with additional depwarn fixes (sbromberger#856) fix deprecation warnings based on local femtocleaner run * use equalto in degeneracy.jl (sbromberger#858) * fix depwarns in linalg submodule (sbromberger#860) * update linalg/spectral to fix deprecations * fix depwarns in graphmatrices * fixes doc deprecation warnings (sbromberger#861) * fixes doc deprecation warnings * adding Base64 to runtests * Update README.md * remove add/remove vertex/edge from core, minor bug fix (sbromberger#862) * remove add/remove vertex/edge from core, minor bug fix * fix tests * export add/rem vertex * remove long-term deprecation warnings (sbromberger#863) * uninitialized -> undef, blkdiag -> blockdiag, and removed import of d… (sbromberger#865) * uninitialized -> undef, blkdiag -> blockdiag, and removed import of deprecated functions from LG to LinAlg * test coverage for digraph eltype * removes equalto (sbromberger#867) * optional sorting algorithm for gdistances (sbromberger#868) add the ability to pass RadixSort to gdistances! * update url and mention directed graphs explicilty (sbromberger#837) * update url and mention directed graphs explicilty * Update graphtypes.md * Update graphtypes.md fixed references. * Speed improvements for function transitiveclosure! (sbromberger#870) * Speed improvements for function transitiveclosure! Instead of checking for all paths i -> k and k -> j for a given vertex k we only iterate over the in- and outneighbours of k. * Merged some conditionals into a single statement * Cache efficient Floyd Warshall (sbromberger#873) * Update floyd-warshall.jl * Cache efficient Floyd Warshall * fixed an error where smallgraph(:frucht) had 20 vertices instead of 12 (sbromberger#878) * Delete .Rhistory * Added function transitivereduction (sbromberger#877) * added function transitivereduction * Update transitivity.jl docstring formatting * Fixed some tests && added testdigraphs for all tests * Johnson Shortest Path for Sparse Graphs (sbromberger#884) * Johnson Shortest Path for Sparse Graphs Johnson Shortest Path for Sparse Graphs * Improved memory efficiency if distmx is mutable * Improved memory efficiency for parallel implementation * Update index.md * Added constructors to create graphs from a vector or an iterator of edges (sbromberger#880) * Added constructors to create SimpleGraphs and SimpleDiGraphs from a vector or an iterator of edges * Added constructors to create SimpleGraphs and SimpleDiGraphs from a vector or an iterator of edges * Slyles1001/892 (sbromberger#894) * comments are your friend * Most of LightGraphs warnings are fixed * Delete HITS.jl * Slyles1001/872 (sbromberger#891) * DataStructures fixed * missed heappop!, now it tests clean * spaces * Update LightGraphs.jl * Update runtests.jl * fixes most depwarns as of 20180529 (sbromberger#895) * fixes most depwarns as of 20180529 * graphmatrices problems * remove tabs * tabs, again * Update CONTRIBUTING.md (sbromberger#897) * Improve Kruskal and use in-built disjoint set data structure (sbromberger#896) * Improve Kruskal and use in-built disjoint set data structure * Update kruskal.jl Changes requested by @somil55
* added function transitivereduction * Update transitivity.jl docstring formatting * Fixed some tests && added testdigraphs for all tests
* ignore coverage file * merge master (#2) * removed flow algorithms (#815) * fixes #820, plus tests (#821) * change show() for empty graphs (ref JuliaGraphs/MetaGraphs.jl#20 (comment)) (#822) * Pull request clique_percolation.jl (#826) clique percolation is a method of uncovering the overlapping community structure of complex networks in nature and society * add src/community/clique_percolation.jl * tests in file test/community/clique_percolation.jl * cites the original clique percolation paper * for undirected graphs only using traitfn * in_ / out_ -> in / out (#830) * (in,out)_neighbors -> (in,out)neighbors * all_neighbors -> allneighbors * Pull request clique_percolation.jl (#826) clique percolation is a method of uncovering the overlapping community structure of complex networks in nature and society * add src/community/clique_percolation.jl * tests in file test/community/clique_percolation.jl * cites the original clique percolation paper * for undirected graphs only using traitfn * revert allneighbors * expected_degree_graph (Chung-Lu model) (#832) * Expected degree random graph generator implemented, including tests * algorithm corrected * Missing seed corrected in expected_degree_graph * expected_degree_graph! implemented * Added return in function, comment with references removed, references in docs added (expected_degree_graph) * Update randgraphs.jl minor doc update * Update randgraphs.jl * Fixing problems with MST Kruskal's on SimpleWeightedGraphs (#835) * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update prim.jl * Update kruskal.jl * Update prim.jl * reverting changes * Revert "reverting changes" This reverts commit ac1760b. * Revert "Update prim.jl" This reverts commit 677f6fa. * Revert "Update kruskal.jl" This reverts commit a0e9c47. * Revert "Update prim.jl" This reverts commit 793bac4. * Revert "Update kruskal.jl" This reverts commit 6114e16. * Revert "Update prim.jl" This reverts commit 551f1e6. * Revert "Update kruskal.jl" This reverts commit 941005e. * Revert "Update kruskal.jl" This reverts commit a404514. * Revert "Update prim.jl" This reverts commit 2d43a60. * Revert "Update kruskal.jl" This reverts commit 4577920. * fix problems with SimpleWeightedGraphs * fix problems with SimpleWeightedGraphs * fix problems with SimpleWeightedGraphs * bipartite_map on 2-order graphs fixed. Added proper tests. Fixed test connected to bipartite_map (#836) * Correct pre-allocation of memory in Prim's MST (#839) * Improve Kruskal's MST by optimizing Union-Find (#843) * add missing backtick (#846) * Add greedy_color for Graph Coloring (#844) * Add greedy_color for Graph Coloring * Improve Kruskal's MST by optimizing Union-Find (#843) * Update README.md * Update README.md * first cut at 0.7 compatibility (#848) * using LightGraphs does not error * Switch to LinearAlgebra and SparseArrays std libs * Fix most of linalg tests * Add SharedArrays for distance tests to compile * Add Random and Markdown to stdlibs used * Fix connectivity tests * IntSet -> BitSet * Add DelimitedFiles stdlib for readcsv * Fix failing test * first cut * Use mauro/SimpleTraits.jl/m3/where-fns in tests * Fix SimpleTraits checkout (#851) * Move up SimpleTraits checkout (#852) * Update runtests.jl * Update REQUIRE * Update REQUIRE * femtocleaner with additional depwarn fixes (#856) fix deprecation warnings based on local femtocleaner run * use equalto in degeneracy.jl (#858) * fix depwarns in linalg submodule (#860) * update linalg/spectral to fix deprecations * fix depwarns in graphmatrices * fixes doc deprecation warnings (#861) * fixes doc deprecation warnings * adding Base64 to runtests * Update README.md * remove add/remove vertex/edge from core, minor bug fix (#862) * remove add/remove vertex/edge from core, minor bug fix * fix tests * export add/rem vertex * remove long-term deprecation warnings (#863) * uninitialized -> undef, blkdiag -> blockdiag, and removed import of d… (#865) * uninitialized -> undef, blkdiag -> blockdiag, and removed import of deprecated functions from LG to LinAlg * test coverage for digraph eltype * removes equalto (#867) * optional sorting algorithm for gdistances (#868) add the ability to pass RadixSort to gdistances! * update url and mention directed graphs explicilty (#837) * update url and mention directed graphs explicilty * Update graphtypes.md * Update graphtypes.md fixed references. * Speed improvements for function transitiveclosure! (#870) * Speed improvements for function transitiveclosure! Instead of checking for all paths i -> k and k -> j for a given vertex k we only iterate over the in- and outneighbours of k. * Merged some conditionals into a single statement * Cache efficient Floyd Warshall (#873) * Update floyd-warshall.jl * Cache efficient Floyd Warshall * fixed an error where smallgraph(:frucht) had 20 vertices instead of 12 (#878) * Delete .Rhistory * Added function transitivereduction (#877) * added function transitivereduction * Update transitivity.jl docstring formatting * Fixed some tests && added testdigraphs for all tests * Johnson Shortest Path for Sparse Graphs (#884) * Johnson Shortest Path for Sparse Graphs Johnson Shortest Path for Sparse Graphs * Improved memory efficiency if distmx is mutable * Improved memory efficiency for parallel implementation * Update index.md * Added constructors to create graphs from a vector or an iterator of edges (#880) * Added constructors to create SimpleGraphs and SimpleDiGraphs from a vector or an iterator of edges * Added constructors to create SimpleGraphs and SimpleDiGraphs from a vector or an iterator of edges * Slyles1001/892 (#894) * comments are your friend * Most of LightGraphs warnings are fixed * Delete HITS.jl * Slyles1001/872 (#891) * DataStructures fixed * missed heappop!, now it tests clean * spaces * Update LightGraphs.jl * Update runtests.jl * fixes most depwarns as of 20180529 (#895) * fixes most depwarns as of 20180529 * graphmatrices problems * remove tabs * tabs, again * Update CONTRIBUTING.md (#897) * Improve Kruskal and use in-built disjoint set data structure (#896) * Improve Kruskal and use in-built disjoint set data structure * Update kruskal.jl Changes requested by @somil55 * updated syntax for iterator protocol * fixed iterator, broken inference
As mentioned in #874 I have implemented a function to calculate the transitive reduction of a graph and added some tests. I've also added a kwargs option
selflooped
in order to mimic the functiontransitveclosure
.For some reason, the docstring I wrote for this function does not appear in my Julia v.07 repl, when entering
?transitivereduction
. Anyone has a clue why this happens?Some remarks:
A case where the algorithm has to do a lot of work is when there are many edges and many strongly connected components (try running it on
g = transitiveclosure!(PathDiGraph(5000))
).The Boost graph library does something similar to calculate the transitive closure, so if someone wants to speed up the
transitiveclosure
function of LightGraphs, they could try something like that.