File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -315,12 +315,15 @@ without any edge values.
315
315
"""
316
316
function weights end
317
317
318
- LG. weights (g:: ZeroEdgeValGraph ) = LG. DefaultDistance (nv (g))
319
-
320
- LG. weights (g:: OneEdgeValGraph ; kwargs... ) = LG. weights (g, 1 ; kwargs... )
321
-
322
318
function LG. weights (g:: AbstractValGraph , key; zerovalue= zero (edgevals_type (g, key)))
323
319
324
320
return ValMatrix (g, key, zerovalue)
325
321
end
326
322
323
+ function LG. weights (g:: AbstractValGraph ; kwargs... )
324
+
325
+ g isa ZeroEdgeValGraph && return LG. DefaultDistance (nv (g))
326
+ g isa OneEdgeValGraph && return weights (g, 1 ; kwargs... )
327
+
328
+ throw (ArgumentError (" g has more than one edge value key. Must specify key." ))
329
+ end
Original file line number Diff line number Diff line change @@ -179,6 +179,12 @@ using LightGraphs: DefaultDistance
179
179
@test weights (g) == DefaultDistance (nv (g))
180
180
end
181
181
182
+ @testset " weights for graph with two edge values and no key specified" begin
183
+
184
+ @test_throws ArgumentError weights (ValGraph (3 , edgeval_types= (a= Int, b= String)))
185
+ @test_throws ArgumentError weights (ValDiGraph (2 , edgeval_types= (Int, String)); zerovalue= nothing )
186
+ end
187
+
182
188
@testset " convert AdjacencyMatrix to SparseMatrixCSC" begin
183
189
184
190
g1 = ValGraph {Int8} (4 )
You can’t perform that action at this time.
0 commit comments