Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DataGraphs"
uuid = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a"
version = "0.5.0"
version = "0.5.1"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org> and contributors"]

[workspace]
Expand Down
7 changes: 5 additions & 2 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ function isassigned_datagraph(graph::AbstractGraph, inds::AbstractGraphIndices)
return all(ind -> isassigned(graph, ind), inds)
end

is_graph_index_assigned(graph::AbstractGraph, vertex) = is_vertex_assigned(graph, vertex)
function is_graph_index_assigned(graph::AbstractGraph{V}, vertex) where {V}
return is_vertex_assigned(graph, convert(V, vertex))
end

function is_graph_index_assigned(graph::AbstractGraph, edge::AbstractEdge)
return is_edge_assigned(graph, arrange_edge(graph, edge))
E = edgetype(graph)
return is_edge_assigned(graph, convert(E, arrange_edge(graph, edge)))
end

# ====================================== setindex! ======================================= #
Expand Down
3 changes: 3 additions & 0 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ using Test: @test, @test_broken, @testset
dg[3] = "V3"
dg[4] = "V4"
@test isassigned(dg, 1)
@test isassigned(dg, 1.0)
@test dg[1] == "V1"
@test dg[2] == "V2"
@test dg[3] == "V3"
Expand All @@ -71,7 +72,9 @@ using Test: @test, @test_broken, @testset
dg[NamedEdge(3, 4)] = :E34
#@test isassigned(dg, (1, 2))
@test isassigned(dg, NamedEdge(2, 3))
@test isassigned(dg, NamedEdge(2.0, 3.0))
@test isassigned(dg, 3 => 4)
@test isassigned(dg, 3.0 => 4.0)
@test dg[NamedEdge(1, 2)] == :E12
@test dg[2 => 3] == :E23
@test dg[3 => 4] == :E34
Expand Down
5 changes: 5 additions & 0 deletions test/test_vertexoredgedatagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ using Test: @test, @test_throws, @testset
@test !isassigned(g, 1)
@test !isassigned(g, 2)
@test !isassigned(g, 3)
@test !isassigned(g, 3.0)
add_edge!(g, NamedEdge(1, 2))
@test !isassigned(g, 1 => 2)
end
Expand All @@ -116,6 +117,7 @@ using Test: @test, @test_throws, @testset
@test isassigned(g, 1)
@test isassigned(g, 2)
@test isassigned(g, 3)
@test isassigned(g, 3.0)
@test g[1] == "V1"
@test g[2] == "V2"
@test g[3] == "V3"
Expand Down Expand Up @@ -302,6 +304,7 @@ using Test: @test, @test_throws, @testset
@test edge_data_type(g) == String
@test !isassigned(g, 1)
@test !isassigned(g, NamedEdge(1, 2))
@test !isassigned(g, NamedEdge(1.0, 2.0))
end

@testset "setindex! and getindex" begin
Expand All @@ -310,6 +313,8 @@ using Test: @test, @test_throws, @testset
g[NamedEdge(1, 2)] = "E12_updated"
@test g[NamedEdge(1, 2)] == "E12_updated"
@test g[NamedEdge(2, 3)] == "E23"
@test isassigned(g, NamedEdge(1.0, 2.0 + 0.0im))
@test g[NamedEdge(2.0, 3.0)] == "E23"
end

@testset "rem_edge!" begin
Expand Down
Loading