Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix convert_vertextype #74

Merged
merged 1 commit into from
Apr 26, 2024
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 src/namedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end

function GraphsExtensions.convert_vertextype(vertextype::Type, graph::GenericNamedGraph)
return GenericNamedGraph(
position_graph(graph), convert(Vector{vertextype}, graph.ordered_vertices)
position_graph(graph), convert(Vector{vertextype}, ordered_vertices(graph))
)
end

Expand Down
13 changes: 12 additions & 1 deletion test/test_namedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ using NamedGraphs.GraphsExtensions:
⊔,
boundary_edges,
boundary_vertices,
convert_vertextype,
degrees,
eccentricities,
dijkstra_mst,
Expand All @@ -82,7 +83,8 @@ using NamedGraphs.GraphsExtensions:
rename_vertices,
subgraph,
symrcm_perm,
symrcm_permute
symrcm_permute,
vertextype
using NamedGraphs.NamedGraphGenerators: named_binary_tree, named_grid, named_path_graph
using SymRCM: SymRCM
using Test: @test, @test_broken, @testset
Expand Down Expand Up @@ -117,6 +119,15 @@ end
@test degree(g, "A") == 1
@test degree(g, "B") == 2

g = NamedGraph(grid((4,)), [2, 4, 6, 8])
g_t = convert_vertextype(UInt16, g)
@test g == g_t
@test nv(g_t) == 4
@test ne(g_t) == 3
@test vertextype(g_t) === UInt16
@test issetequal(vertices(g_t), UInt16[2, 4, 6, 8])
@test eltype(vertices(g_t)) === UInt16

g = NamedGraph(grid((4,)), ["A", "B", "C", "D"])
zg = zero(g)
@test zg isa NamedGraph{String}
Expand Down
Loading