Skip to content

Commit

Permalink
Document default direction (:both) in laplacian_matrix and others (
Browse files Browse the repository at this point in the history
…#41)

Partially solves #24 without breaking backwards compatibility
  • Loading branch information
gdalle committed Apr 6, 2023
1 parent 4b2d7ff commit d995ffd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/overrides.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
degree_matrix(g, T; dir)
Construct the weighted diagonal degree matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
Construct the weighted diagonal degree matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]` (default is `:out`).
"""
function degree_matrix(
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out
Expand All @@ -25,7 +25,7 @@ end
"""
Graphs.adjacency_matrix(g, T; dir)
Construct the weighted adjacency matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
Construct the weighted adjacency matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]` (default is `:out`).
"""
function Graphs.adjacency_matrix(
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out
Expand All @@ -40,7 +40,7 @@ end
"""
Graphs.laplacian_matrix(g, T; dir)
Subtract the adjacency matrix to the degree matrix, both filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
Subtract the adjacency matrix to the degree matrix, both filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]` (unlike in Graphs.jl, default is `:out`).
"""
function Graphs.laplacian_matrix(
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out
Expand Down
8 changes: 4 additions & 4 deletions test/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
@test degree_matrix(g, Float64; dir=:out) == degree_matrix(g, Float64; dir=:in)
@test adjacency_matrix(g)[2, 4] == 0
@test adjacency_matrix(g; dir=:out) == adjacency_matrix(g; dir=:in)'
@test issymmetric(laplacian_matrix(g))
@test laplacian_matrix(g, Float64) g3_l
@test issymmetric(laplacian_matrix(g; dir=:out))
@test laplacian_matrix(g, Float64; dir=:out) g3_l
@test g[1:3] == SimpleWeightedGraph{eltype(g),weighttype(g)}(path_graph(3))
gx = copy(g)
add_edge!(gx, 2, 3, 99)
Expand All @@ -74,8 +74,8 @@
@test_throws DomainError degree_matrix(g, dir=:other)
@test @inferred(adjacency_matrix(g, Int64)) == adjacency_matrix(g, Int64; dir=:out)
@test adjacency_matrix(g; dir=:out) == adjacency_matrix(g; dir=:in)'
@test !issymmetric(laplacian_matrix(g))
@test laplacian_matrix(g, Float64) g5_l
@test !issymmetric(laplacian_matrix(g; dir=:out))
@test laplacian_matrix(g, Float64; dir=:out) g5_l
@test @inferred(pagerank(g))[3] 0.2266 atol = 0.001
@test length(@inferred(pagerank(g))) == nv(g)
@test_throws ErrorException pagerank(g, 2)
Expand Down

0 comments on commit d995ffd

Please sign in to comment.