Skip to content

Commit

Permalink
Fix convert_vertextype (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Apr 26, 2024
1 parent b8fd114 commit c59dffe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit c59dffe

Please sign in to comment.