Skip to content

Commit 0fa5f52

Browse files
authored
Fix most failing doctests (#305)
1 parent 0894eb8 commit 0fa5f52

File tree

5 files changed

+22
-57
lines changed

5 files changed

+22
-57
lines changed

docs/Manifest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
7676

7777
[[deps.Graphs]]
7878
deps = ["ArnoldiMethod", "Compat", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"]
79-
path = "/home/hyrodium/.julia/dev/Graphs"
79+
path = ".."
8080
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
8181
version = "1.8.0"
8282

@@ -227,9 +227,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
227227

228228
[[deps.StaticArrays]]
229229
deps = ["LinearAlgebra", "Random", "StaticArraysCore"]
230-
git-tree-sha1 = "9cabadf6e7cd2349b6cf49f1915ad2028d65e881"
230+
git-tree-sha1 = "51621cca8651d9e334a659443a74ce50a3b6dfab"
231231
uuid = "90137ffa-7385-5640-81b9-e52037218182"
232-
version = "1.6.2"
232+
version = "1.6.3"
233233
weakdeps = ["Statistics"]
234234

235235
[deps.StaticArrays.extensions]

src/Experimental/ShortestPaths/ShortestPaths.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ algorithm `alg` (one of [`BellmanFord`](@ref) or [`SPFA`](@ref)), return
181181
`true` if any cycle detected in the graph has a negative weight.
182182
# Examples
183183
184-
```
185-
julia> using Graphs
184+
```jldoctest
185+
julia> using Graphs, Graphs.Experimental.ShortestPaths
186186
187187
julia> g = complete_graph(3);
188188

src/community/modularity.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,21 @@ julia> modularity(barbell, [1, 1, 1, 2, 2, 2])
5353
julia> modularity(barbell, [1, 1, 1, 2, 2, 2], γ=0.5)
5454
0.6071428571428571
5555
```
56-
```
57-
julia> using SimpleWeightedGraphs
58-
59-
julia> triangle = SimpleWeightedGraph(3);
56+
```jldoctest
57+
julia> using Graphs
6058
61-
julia> add_edge!(triangle, 1, 2, 1);
59+
julia> triangle = cycle_graph(3);
6260
63-
julia> add_edge!(triangle, 2, 3, 1);
61+
julia> barbell = blockdiag(triangle, triangle);
6462
65-
julia> add_edge!(triangle, 3, 1, 1);
63+
julia> add_edge!(barbell, 1, 4);
6664
67-
julia> barbell = blockdiag(triangle, triangle);
65+
julia> distmx = Matrix(weights(barbell));
6866
69-
julia> add_edge!(barbell, 1, 4, 5); # this edge has a weight of 5
67+
julia> distmx[1, 4] = distmx[4, 1] = 5; # additional edge has a weight of 5
7068
71-
julia> modularity(barbell, [1, 1, 1, 2, 2, 2])
72-
0.045454545454545456
69+
julia> round(modularity(barbell, [1, 1, 1, 2, 2, 2]; distmx), digits=6)
70+
0.045455
7371
```
7472
"""
7573
function modularity(

src/digraph/transitivity.jl

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,52 +54,18 @@ is `true`, add self loops to the graph.
5454
Time complexity is ``\\mathcal{O}(|E||V|)``.
5555
5656
# Examples
57-
```
57+
```jldoctest
5858
julia> using Graphs
5959
6060
julia> barbell = blockdiag(complete_digraph(3), complete_digraph(3));
6161
6262
julia> add_edge!(barbell, 1, 4);
6363
64-
julia> collect(edges(barbell))
65-
13-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:
66-
Edge 1 => 2
67-
Edge 1 => 3
68-
Edge 1 => 4
69-
Edge 2 => 1
70-
Edge 2 => 3
71-
Edge 3 => 1
72-
Edge 3 => 2
73-
Edge 4 => 5
74-
Edge 4 => 6
75-
Edge 5 => 4
76-
Edge 5 => 6
77-
Edge 6 => 4
78-
Edge 6 => 5
64+
julia> ne(barbell)
65+
13
7966
80-
julia> collect(edges(transitiveclosure(barbell)))
81-
21-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:
82-
Edge 1 => 2
83-
Edge 1 => 3
84-
Edge 1 => 4
85-
Edge 1 => 5
86-
Edge 1 => 6
87-
Edge 2 => 1
88-
Edge 2 => 3
89-
Edge 2 => 4
90-
Edge 2 => 5
91-
Edge 2 => 6
92-
Edge 3 => 1
93-
Edge 3 => 2
94-
Edge 3 => 4
95-
Edge 3 => 5
96-
Edge 3 => 6
97-
Edge 4 => 5
98-
Edge 4 => 6
99-
Edge 5 => 4
100-
Edge 5 => 6
101-
Edge 6 => 4
102-
Edge 6 => 5
67+
julia> ne(transitiveclosure(barbell))
68+
21
10369
```
10470
"""
10571
function transitiveclosure(g::DiGraph, selflooped=false)

src/shortestpaths/spfa.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ julia> spfa_shortest_paths(g, 1, d)
3434
0
3535
```
3636
37-
```
37+
```jldoctest
38+
julia> using Graphs
3839
3940
julia> g = complete_graph(3);
4041
4142
julia> d = [1 -3 1; -3 1 1; 1 1 1];
4243
4344
julia> spfa_shortest_paths(g, 1, d)
44-
4545
ERROR: Graphs.NegativeCycleError()
46+
[...]
4647
```
4748
"""
4849
function spfa_shortest_paths(

0 commit comments

Comments
 (0)