diff --git a/README.md b/README.md index 5fb375f..eed2a84 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ julia> using NamedGraphs julia> g = NamedGraph(grid((4,)), ["A", "B", "C", "D"]) NamedGraph{String} with 4 vertices: -4-element Indices{String} +4-element Dictionaries.Indices{String} "A" "B" "C" @@ -61,7 +61,7 @@ and 3 edge(s): julia> g = NamedGraph(grid((4,)); vertices=["A", "B", "C", "D"]) # Same as above NamedGraph{String} with 4 vertices: -4-element Indices{String} +4-element Dictionaries.Indices{String} "A" "B" "C" @@ -92,9 +92,9 @@ julia> neighbors(g, "B") "A" "C" -julia> g[["A", "B"]] +julia> subgraph(g, ["A", "B"]) NamedGraph{String} with 2 vertices: -2-element Indices{String} +2-element Dictionaries.Indices{String} "A" "B" @@ -113,13 +113,12 @@ Graph operations are implemented by mapping back and forth between the generaliz It is natural to use tuples of integers as the names for the vertices of graphs with grid connectivities. -For this, we use the convention that if a tuple is input, it is interpreted as the grid size and -the vertex names label cartesian coordinates: +For example: ```julia -julia> g = NamedGraph(grid((2, 2)); vertices=(2, 2)) +julia> g = NamedGraph(grid((2, 2)); vertices=Tuple.(CartesianIndices((2, 2)))) NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Indices{Tuple{Int64, Int64}} +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -134,6 +133,7 @@ and 4 edge(s): ``` +In the future we will provide a shorthand notation for this, such as `cartesian_graph(grid((2, 2)), (2, 2))`. Internally the vertices are all stored as tuples with a label in each dimension. @@ -162,7 +162,7 @@ You can use vertex names to get [induced subgraphs](https://juliagraphs.org/Grap ```julia julia> subgraph(v -> v[1] == 1, g) NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Indices{Tuple{Int64, Int64}} +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (1, 2) @@ -172,7 +172,7 @@ and 1 edge(s): julia> subgraph(v -> v[2] == 2, g) NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Indices{Tuple{Int64, Int64}} +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 2) (2, 2) @@ -180,9 +180,9 @@ and 1 edge(s): (1, 2) => (2, 2) -julia> g[[(1, 1), (2, 2)]] +julia> subgraph(g, [(1, 1), (2, 2)]) NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Indices{Tuple{Int64, Int64}} +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 2) @@ -191,16 +191,12 @@ and 0 edge(s): ``` -Note that this is similar to multidimensional array slicing, and we may support syntax like `subgraph(v, 1, :)` in the future. - - - You can also take [disjoint unions](https://en.wikipedia.org/wiki/Disjoint_union) or concatenations of graphs: ```julia julia> g₁ = g NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Indices{Tuple{Int64, Int64}} +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -215,7 +211,7 @@ and 4 edge(s): julia> g₂ = g NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Indices{Tuple{Int64, Int64}} +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -230,7 +226,7 @@ and 4 edge(s): julia> disjoint_union(g₁, g₂) NamedGraph{Tuple{Tuple{Int64, Int64}, Int64}} with 8 vertices: -8-element Indices{Tuple{Tuple{Int64, Int64}, Int64}} +8-element Dictionaries.Indices{Tuple{Tuple{Int64, Int64}, Int64}} ((1, 1), 1) ((2, 1), 1) ((1, 2), 1) @@ -253,7 +249,7 @@ and 8 edge(s): julia> g₁ ⊔ g₂ # Same as above NamedGraph{Tuple{Tuple{Int64, Int64}, Int64}} with 8 vertices: -8-element Indices{Tuple{Tuple{Int64, Int64}, Int64}} +8-element Dictionaries.Indices{Tuple{Tuple{Int64, Int64}, Int64}} ((1, 1), 1) ((2, 1), 1) ((1, 2), 1) @@ -293,7 +289,7 @@ The original graphs can be obtained from subgraphs: ```julia julia> rename_vertices(v -> v[1], subgraph(v -> v[2] == 1, g₁ ⊔ g₂)) NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Indices{Tuple{Int64, Int64}} +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -308,7 +304,7 @@ and 4 edge(s): julia> rename_vertices(v -> v[1], subgraph(v -> v[2] == 2, g₁ ⊔ g₂)) NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Indices{Tuple{Int64, Int64}} +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) diff --git a/examples/Project.toml b/examples/Project.toml index 295df54..9c9817e 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,3 +1,4 @@ [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19" +Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" diff --git a/examples/README.jl b/examples/README.jl index e3cbe5c..2fa71d7 100644 --- a/examples/README.jl +++ b/examples/README.jl @@ -37,19 +37,19 @@ has_vertex(g, "A") has_edge(g, "A" => "B") has_edge(g, "A" => "C") neighbors(g, "B") -g[["A", "B"]] +subgraph(g, ["A", "B"]) #' Internally, this type wraps a `SimpleGraph`, and stores a `Dictionary` from the [Dictionaries.jl](https://github.com/andyferris/Dictionaries.jl) package that maps the vertex names to the linear indices of the underlying `SimpleGraph`. #' Graph operations are implemented by mapping back and forth between the generalized named vertices and the linear index vertices of the `SimpleGraph`. #' It is natural to use tuples of integers as the names for the vertices of graphs with grid connectivities. -#' For this, we use the convention that if a tuple is input, it is interpreted as the grid size and -#' the vertex names label cartesian coordinates: +#' For example: #+ term=true -g = NamedGraph(grid((2, 2)); vertices=(2, 2)) +g = NamedGraph(grid((2, 2)); vertices=Tuple.(CartesianIndices((2, 2)))) +#' In the future we will provide a shorthand notation for this, such as `cartesian_graph(grid((2, 2)), (2, 2))`. #' Internally the vertices are all stored as tuples with a label in each dimension. #' Vertices can be referred to by their tuples: @@ -65,9 +65,7 @@ neighbors(g, (2, 2)) subgraph(v -> v[1] == 1, g) subgraph(v -> v[2] == 2, g) -g[[(1, 1), (2, 2)]] - -#' Note that this is similar to multidimensional array slicing, and we may support syntax like `subgraph(v, 1, :)` in the future. +subgraph(g, [(1, 1), (2, 2)]) #' You can also take [disjoint unions](https://en.wikipedia.org/wiki/Disjoint_union) or concatenations of graphs: #+ term=true diff --git a/src/Graphs/abstractgraph.jl b/src/Graphs/abstractgraph.jl index c73ecd0..394ecfa 100644 --- a/src/Graphs/abstractgraph.jl +++ b/src/Graphs/abstractgraph.jl @@ -57,9 +57,7 @@ vertextype(graph::AbstractGraph) = vertextype(typeof(graph)) # Function `f` maps original vertices `vᵢ` of `g` # to new vertices `f(vᵢ)` of the output graph. -function rename_vertices(f::Function, g::AbstractGraph) - return set_vertices(g, f.(vertices(g))) -end +rename_vertices(f::Function, g::AbstractGraph) = not_implemented() function rename_vertices(g::AbstractGraph, name_map) return rename_vertices(v -> name_map[v], g) diff --git a/src/Graphs/partitionedgraphs/abstractpartitionedgraph.jl b/src/Graphs/partitionedgraphs/abstractpartitionedgraph.jl index 169c3fb..74d82df 100644 --- a/src/Graphs/partitionedgraphs/abstractpartitionedgraph.jl +++ b/src/Graphs/partitionedgraphs/abstractpartitionedgraph.jl @@ -31,6 +31,9 @@ parent_graph(pg::AbstractPartitionedGraph) = parent_graph(unpartitioned_graph(pg function vertex_to_parent_vertex(pg::AbstractPartitionedGraph, vertex) return vertex_to_parent_vertex(unpartitioned_graph(pg), vertex) end +function parent_vertex_to_vertex(pg::AbstractPartitionedGraph, parent_vertex) + return parent_vertex_to_vertex(unpartitioned_graph(pg), parent_vertex) +end edgetype(pg::AbstractPartitionedGraph) = edgetype(unpartitioned_graph(pg)) parent_graph_type(pg::AbstractPartitionedGraph) = parent_graph_type(unpartitioned_graph(pg)) nv(pg::AbstractPartitionedGraph, pv::AbstractPartitionVertex) = length(vertices(pg, pv)) diff --git a/src/Graphs/partitionedgraphs/partitionedgraph.jl b/src/Graphs/partitionedgraphs/partitionedgraph.jl index 61984ec..23c5a3e 100644 --- a/src/Graphs/partitionedgraphs/partitionedgraph.jl +++ b/src/Graphs/partitionedgraphs/partitionedgraph.jl @@ -53,7 +53,7 @@ function partitionvertex(pg::PartitionedGraph, vertex) return PartitionVertex(which_partition(pg)[vertex]) end -function partitionvertices(pg::PartitionedGraph, verts::Vector) +function partitionvertices(pg::PartitionedGraph, verts) return unique(partitionvertex(pg, v) for v in verts) end @@ -94,9 +94,7 @@ function edges(pg::PartitionedGraph, partitionedges::Vector{<:PartitionEdge}) return unique(reduce(vcat, [edges(pg, pe) for pe in partitionedges])) end -function boundary_partitionedges( - pg::PartitionedGraph, partitionvertices::Vector{<:PartitionVertex}; kwargs... -) +function boundary_partitionedges(pg::PartitionedGraph, partitionvertices; kwargs...) return PartitionEdge.( boundary_edges(partitioned_graph(pg), parent.(partitionvertices); kwargs...) ) @@ -150,7 +148,7 @@ function delete_from_vertex_map!( end ### PartitionedGraph Specific Functions -function induced_subgraph(pg::PartitionedGraph, vertices::Vector) +function partitionedgraph_induced_subgraph(pg::PartitionedGraph, vertices::Vector) sub_pg_graph, _ = induced_subgraph(unpartitioned_graph(pg), vertices) sub_partitioned_vertices = copy(partitioned_vertices(pg)) for pv in NamedGraphs.vertices(partitioned_graph(pg)) @@ -165,8 +163,17 @@ function induced_subgraph(pg::PartitionedGraph, vertices::Vector) return PartitionedGraph(sub_pg_graph, sub_partitioned_vertices), nothing end -function induced_subgraph( - pg::PartitionedGraph, partitionverts::Vector{V} -) where {V<:PartitionVertex} +function partitionedgraph_induced_subgraph( + pg::PartitionedGraph, partitionverts::Vector{<:PartitionVertex} +) return induced_subgraph(pg, vertices(pg, partitionverts)) end + +function Graphs.induced_subgraph(pg::PartitionedGraph, vertices) + return partitionedgraph_induced_subgraph(pg, vertices) +end + +# Fixes ambiguity error with `Graphs.jl`. +function Graphs.induced_subgraph(pg::PartitionedGraph, vertices::Vector{<:Integer}) + return partitionedgraph_induced_subgraph(pg, vertices) +end diff --git a/src/abstractnamedgraph.jl b/src/abstractnamedgraph.jl index fa6bf96..df82183 100644 --- a/src/abstractnamedgraph.jl +++ b/src/abstractnamedgraph.jl @@ -15,6 +15,8 @@ parent_graph_type(graph::AbstractNamedGraph) = not_implemented() rem_vertex!(graph::AbstractNamedGraph, vertex) = not_implemented() add_vertex!(graph::AbstractNamedGraph, vertex) = not_implemented() +rename_vertices(f::Function, g::AbstractNamedGraph) = not_implemented() + # Convert vertex to parent vertex # Inverse map of `parent_vertex_to_vertex`. vertex_to_parent_vertex(graph::AbstractNamedGraph, vertex) = not_implemented() @@ -521,29 +523,38 @@ function tree(graph::AbstractNamedGraph, parents) return t end -function _bfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) +function namedgraph_bfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) return tree(graph, bfs_parents(graph, vertex; kwargs...)) end # Disambiguation from Graphs.bfs_tree function bfs_tree(graph::AbstractNamedGraph, vertex::Integer; kwargs...) - return _bfs_tree(graph, vertex; kwargs...) + return namedgraph_bfs_tree(graph, vertex; kwargs...) +end +function bfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) + return namedgraph_bfs_tree(graph, vertex; kwargs...) end -bfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) = _bfs_tree(graph, vertex; kwargs...) # Returns a Dictionary mapping a vertex to it's parent # vertex in the traversal/spanning tree. -function _bfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) +function namedgraph_bfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) parent_bfs_parents = bfs_parents( parent_graph(graph), vertex_to_parent_vertex(graph, vertex); kwargs... ) - return Dictionary(vertices(graph), parent_vertices_to_vertices(graph, parent_bfs_parents)) + # Works around issue in this `Dictionary` constructor: + # https://github.com/andyferris/Dictionaries.jl/blob/v0.4.1/src/Dictionary.jl#L139-L145 + # when `inds` has holes. This removes the holes. + # TODO: Raise an issue with `Dictionaries.jl`. + ## vertices_graph = Indices(collect(vertices(graph))) + # This makes the vertices ordered according to the parent vertices. + vertices_graph = parent_vertices_to_vertices(graph, parent_vertices(graph)) + return Dictionary(vertices_graph, parent_vertices_to_vertices(graph, parent_bfs_parents)) end # Disambiguation from Graphs.bfs_tree function bfs_parents(graph::AbstractNamedGraph, vertex::Integer; kwargs...) - return _bfs_parents(graph, vertex; kwargs...) + return namedgraph_bfs_parents(graph, vertex; kwargs...) end function bfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) - return _bfs_parents(graph, vertex; kwargs...) + return namedgraph_bfs_parents(graph, vertex; kwargs...) end # diff --git a/src/namedgraph.jl b/src/namedgraph.jl index 53d33f0..bf68953 100644 --- a/src/namedgraph.jl +++ b/src/namedgraph.jl @@ -13,6 +13,8 @@ end function parent_vertex_to_vertex(graph::GenericNamedGraph, parent_vertex) return graph.parent_vertex_to_vertex[parent_vertex] end + +# TODO: Order them according to the internal ordering? vertices(graph::GenericNamedGraph) = keys(graph.vertex_to_parent_vertex) function add_vertex!(graph::GenericNamedGraph, vertex) @@ -38,15 +40,20 @@ function rem_vertex!(graph::GenericNamedGraph, vertex) last_vertex = last(graph.parent_vertex_to_vertex) graph.parent_vertex_to_vertex[parent_vertex] = last_vertex last_vertex = pop!(graph.parent_vertex_to_vertex) - # Insert the last vertex into the position of the vertex - # that is being deleted, then remove the last vertex. graph.vertex_to_parent_vertex[last_vertex] = parent_vertex delete!(graph.vertex_to_parent_vertex, vertex) return true end +function rename_vertices(f::Function, g::GenericNamedGraph) + # TODO: Could be `set_vertices(g, f.(g.parent_vertex_to_vertex))`. + return GenericNamedGraph(g.parent_graph, f.(g.parent_vertex_to_vertex)) +end + function convert_vertextype(V::Type, graph::GenericNamedGraph) - return GenericNamedGraph(parent_graph(graph), convert(Vector{V}, vertices(graph))) + return GenericNamedGraph( + parent_graph(graph), convert(Vector{V}, graph.parent_vertex_to_vertex) + ) end # @@ -182,7 +189,7 @@ end # graph = set_parent_graph(graph, copy(parent_graph(graph))) # graph = set_vertices(graph, copy(vertices(graph))) function copy(graph::GenericNamedGraph) - return GenericNamedGraph(copy(parent_graph(graph)), copy(vertices(graph))) + return GenericNamedGraph(copy(graph.parent_graph), copy(graph.parent_vertex_to_vertex)) end edgetype(G::Type{<:GenericNamedGraph}) = NamedEdge{vertextype(G)} @@ -202,7 +209,7 @@ end is_directed(G::Type{<:GenericNamedGraph}) = is_directed(parent_graph_type(G)) # TODO: Implement an edgelist version -function induced_subgraph(graph::AbstractNamedGraph, subvertices) +function namedgraph_induced_subgraph(graph::AbstractGraph, subvertices) subgraph = typeof(graph)(subvertices) subvertices_set = Set(subvertices) for src in subvertices @@ -215,6 +222,14 @@ function induced_subgraph(graph::AbstractNamedGraph, subvertices) return subgraph, nothing end +function induced_subgraph(graph::AbstractNamedGraph, subvertices) + return namedgraph_induced_subgraph(graph, subvertices) +end + +function induced_subgraph(graph::AbstractNamedGraph, subvertices::Vector{<:Integer}) + return namedgraph_induced_subgraph(graph, subvertices) +end + # # Type aliases # diff --git a/src/shortestpaths.jl b/src/shortestpaths.jl index 21f0fe4..a7fc997 100644 --- a/src/shortestpaths.jl +++ b/src/shortestpaths.jl @@ -28,13 +28,20 @@ function parent_path_state_to_path_state( pᵢ = parent_path_state.parents[i] return iszero(pᵢ) ? i : pᵢ end + # Works around issue in this `Dictionary` constructor: + # https://github.com/andyferris/Dictionaries.jl/blob/v0.4.1/src/Dictionary.jl#L139-L145 + # when `inds` has holes. This removes the holes. + # TODO: Raise an issue with `Dictionaries.jl`. + ## vertices_graph = Indices(collect(vertices(graph))) + # This makes the vertices ordered according to the parent vertices. + vertices_graph = parent_vertices_to_vertices(graph, parent_vertices(graph)) return NamedDijkstraState( Dictionary( - vertices(graph), parent_vertices_to_vertices(graph, parent_path_state_parents) + vertices_graph, parent_vertices_to_vertices(graph, parent_path_state_parents) ), - Dictionary(vertices(graph), parent_path_state.dists), + Dictionary(vertices_graph, parent_path_state.dists), map(x -> parent_vertices_to_vertices(graph, x), parent_path_state.predecessors), - Dictionary(vertices(graph), parent_path_state.pathcounts), + Dictionary(vertices_graph, parent_path_state.pathcounts), parent_vertices_to_vertices(graph, parent_path_state.closest_vertices), ) end diff --git a/src/traversals/dfs.jl b/src/traversals/dfs.jl index 44033fc..84b1b9d 100644 --- a/src/traversals/dfs.jl +++ b/src/traversals/dfs.jl @@ -2,26 +2,35 @@ return parent_vertices_to_vertices(g, topological_sort_by_dfs(parent_graph(g))) end -function _dfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) +function namedgraph_dfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) return tree(graph, dfs_parents(graph, vertex; kwargs...)) end function dfs_tree(graph::AbstractNamedGraph, vertex::Integer; kwargs...) - return _dfs_tree(graph, vertex; kwargs...) + return namedgraph_dfs_tree(graph, vertex; kwargs...) +end +function dfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) + return namedgraph_dfs_tree(graph, vertex; kwargs...) end -dfs_tree(graph::AbstractNamedGraph, vertex; kwargs...) = _dfs_tree(graph, vertex; kwargs...) # Returns a Dictionary mapping a vertex to it's parent # vertex in the traversal/spanning tree. -function _dfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) +function namedgraph_dfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) parent_dfs_parents = dfs_parents( parent_graph(graph), vertex_to_parent_vertex(graph, vertex); kwargs... ) - return Dictionary(vertices(graph), parent_vertices_to_vertices(graph, parent_dfs_parents)) + # Works around issue in this `Dictionary` constructor: + # https://github.com/andyferris/Dictionaries.jl/blob/v0.4.1/src/Dictionary.jl#L139-L145 + # when `inds` has holes. This removes the holes. + # TODO: Raise an issue with `Dictionaries.jl`. + ## vertices_graph = Indices(collect(vertices(graph))) + # This makes the vertices ordered according to the parent vertices. + vertices_graph = parent_vertices_to_vertices(graph, parent_vertices(graph)) + return Dictionary(vertices_graph, parent_vertices_to_vertices(graph, parent_dfs_parents)) end # Disambiguation from Graphs.dfs_tree function dfs_parents(graph::AbstractNamedGraph, vertex::Integer; kwargs...) - return _dfs_parents(graph, vertex; kwargs...) + return namedgraph_dfs_parents(graph, vertex; kwargs...) end function dfs_parents(graph::AbstractNamedGraph, vertex; kwargs...) - return _dfs_parents(graph, vertex; kwargs...) + return namedgraph_dfs_parents(graph, vertex; kwargs...) end diff --git a/test/Project.toml b/test/Project.toml index 82b72d8..073d95f 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889" +ITensorUnicodePlots = "73163f41-4a9e-479f-8353-73bf94dbd758" KaHyPar = "2a6221f6-aa48-11e9-3542-2d9e0ef01880" Metis = "2679e427-3c69-5b7f-982b-ece356f1e94b" NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19" diff --git a/test/test_partitionedgraph.jl b/test/test_partitionedgraph.jl index a551ada..c103a48 100644 --- a/test/test_partitionedgraph.jl +++ b/test/test_partitionedgraph.jl @@ -23,7 +23,7 @@ using Graphs pg = PartitionedGraph(g, partitions) @test vertextype(partitioned_graph(pg)) == Int64 @test vertextype(unpartitioned_graph(pg)) == vertextype(g) - @test isa(partitionvertices(pg), Vector{PartitionVertex{Int64}}) + @test isa(partitionvertices(pg), Dictionary{Int64,PartitionVertex{Int64}}) @test isa(partitionedges(pg), Vector{PartitionEdge{Int64,NamedEdge{Int64}}}) @test is_tree(partitioned_graph(pg)) @test nv(pg) == nx * ny @@ -36,7 +36,10 @@ using Graphs pg = PartitionedGraph(g, partition_dict) @test vertextype(partitioned_graph(pg)) == vertextype(g) @test vertextype(unpartitioned_graph(pg)) == vertextype(g) - @test isa(partitionvertices(pg), Vector{PartitionVertex{Tuple{Int64,Int64}}}) + @test isa( + partitionvertices(pg), + Dictionary{Tuple{Int64,Int64},PartitionVertex{Tuple{Int64,Int64}}}, + ) @test isa( partitionedges(pg), Vector{PartitionEdge{Tuple{Int64,Int64},NamedEdge{Tuple{Int64,Int64}}}}, diff --git a/test/test_trees_and_forests.jl b/test/test_trees_and_forests.jl index ac84342..a42a775 100644 --- a/test/test_trees_and_forests.jl +++ b/test/test_trees_and_forests.jl @@ -1,7 +1,7 @@ using Test using Graphs using NamedGraphs -using NamedGraphs: forest_cover, spanning_tree +using NamedGraphs: all_edges, forest_cover, spanning_tree module TestTreesAndForests using NamedGraphs @@ -22,8 +22,8 @@ end s_tree = spanning_tree(g; alg) @test is_tree(s_tree) - @test Set(vertices(s_tree)) == Set(vertices(g)) - @test issubset(Set(edges(s_tree)), Set(edges(g))) + @test issetequal(vertices(s_tree), vertices(g)) + @test issubset(all_edges(s_tree), all_edges(g)) end @testset "Test Forest Cover $g_string" for (g_string, g) in TestTreesAndForests.gs