Skip to content

Commit d995ffd

Browse files
authored
Document default direction (:both) in laplacian_matrix and others (#41)
Partially solves #24 without breaking backwards compatibility
1 parent 4b2d7ff commit d995ffd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/overrides.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
degree_matrix(g, T; dir)
33
4-
Construct the weighted diagonal degree matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
4+
Construct the weighted diagonal degree matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]` (default is `:out`).
55
"""
66
function degree_matrix(
77
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out
@@ -25,7 +25,7 @@ end
2525
"""
2626
Graphs.adjacency_matrix(g, T; dir)
2727
28-
Construct the weighted adjacency matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
28+
Construct the weighted adjacency matrix, filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]` (default is `:out`).
2929
"""
3030
function Graphs.adjacency_matrix(
3131
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out
@@ -40,7 +40,7 @@ end
4040
"""
4141
Graphs.laplacian_matrix(g, T; dir)
4242
43-
Subtract the adjacency matrix to the degree matrix, both filled with element type `T` and considering edge direction `dir ∈ [:in, :out, :both]`.
43+
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`).
4444
"""
4545
function Graphs.laplacian_matrix(
4646
g::AbstractSimpleWeightedGraph, T::DataType=weighttype(g); dir::Symbol=:out

test/overrides.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
@test degree_matrix(g, Float64; dir=:out) == degree_matrix(g, Float64; dir=:in)
4848
@test adjacency_matrix(g)[2, 4] == 0
4949
@test adjacency_matrix(g; dir=:out) == adjacency_matrix(g; dir=:in)'
50-
@test issymmetric(laplacian_matrix(g))
51-
@test laplacian_matrix(g, Float64) g3_l
50+
@test issymmetric(laplacian_matrix(g; dir=:out))
51+
@test laplacian_matrix(g, Float64; dir=:out) g3_l
5252
@test g[1:3] == SimpleWeightedGraph{eltype(g),weighttype(g)}(path_graph(3))
5353
gx = copy(g)
5454
add_edge!(gx, 2, 3, 99)
@@ -74,8 +74,8 @@
7474
@test_throws DomainError degree_matrix(g, dir=:other)
7575
@test @inferred(adjacency_matrix(g, Int64)) == adjacency_matrix(g, Int64; dir=:out)
7676
@test adjacency_matrix(g; dir=:out) == adjacency_matrix(g; dir=:in)'
77-
@test !issymmetric(laplacian_matrix(g))
78-
@test laplacian_matrix(g, Float64) g5_l
77+
@test !issymmetric(laplacian_matrix(g; dir=:out))
78+
@test laplacian_matrix(g, Float64; dir=:out) g5_l
7979
@test @inferred(pagerank(g))[3] 0.2266 atol = 0.001
8080
@test length(@inferred(pagerank(g))) == nv(g)
8181
@test_throws ErrorException pagerank(g, 2)

0 commit comments

Comments
 (0)