From 49ccb52c6a11205b784b4975877dd7577e8abce0 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Fri, 28 Aug 2026 16:33:44 -0400 Subject: [PATCH 1/2] Remove the GraphsExtensions submodule Moves the contents of the `GraphsExtensions` submodule into `NamedGraphs` directly, so downstream stops naming it. The submodule encapsulated nothing: all twelve of its exports were already re-exported, and Julia does not enforce submodule privacy. --- docs/src/changelog.md | 4 +++ docs/src/dev_interface.md | 7 ++-- docs/src/reference.md | 6 ---- examples/boundary.jl | 5 ++- examples/mincut.jl | 3 +- .../NamedGraphsGraphsFlowsExt.jl | 3 +- .../NamedGraphsKaHyParExt.jl | 6 ++-- .../NamedGraphsMetisExt.jl | 6 ++-- .../NamedGraphsSimpleGraphAlgorithmsExt.jl | 1 - .../NamedGraphsSymRCMExt.jl | 4 +-- src/GraphsExtensions/GraphsExtensions.jl | 33 ------------------- src/NamedGraphs.jl | 19 +++++++---- .../abstractpartitionedgraph.jl | 12 +++---- src/PartitionedGraphs/partitionedgraph.jl | 11 +++---- src/PartitionedGraphs/quotientedge.jl | 5 ++- src/PartitionedGraphs/quotientvertex.jl | 7 ++-- src/PartitionedGraphs/quotientview.jl | 9 +++-- src/abstractnamededge.jl | 15 ++++----- src/abstractnamedgraph.jl | 10 +++--- src/decorate.jl | 5 ++- src/distance.jl | 1 - src/distances_and_capacities.jl | 6 ++-- src/graph_unions.jl | 4 +-- .../abstractgraph.jl | 2 -- .../abstracttrees.jl | 0 .../arrange_edges.jl | 0 .../boundary.jl | 0 .../graphgenerators.jl | 0 .../neighbors.jl | 0 .../partitioning.jl | 0 .../shortestpaths.jl | 0 .../simplegraph.jl | 0 .../symrcm.jl | 0 .../trees_and_forests.jl | 0 src/indicesviews.jl | 1 - src/namededge.jl | 5 ++- src/namedgraph.jl | 9 +++-- src/namedgraphgenerators.jl | 14 +++----- src/similar_graph.jl | 13 ++++---- src/trees_and_forests.jl | 3 -- test/test_abstractgraph.jl | 7 ++-- test/test_abstractnamedgraph.jl | 6 ++-- test/test_cycles.jl | 5 ++- test/test_exports.jl | 22 ------------- test/test_graphdecoration.jl | 4 +-- test/test_graphsextensions.jl | 27 ++++++++------- test/test_namedgraph.jl | 13 ++++---- test/test_namedgraphgenerators.jl | 6 ++-- test/test_partitionedgraph.jl | 8 ++--- test/test_random_bfs_tree.jl | 3 +- test/test_staticgraphs.jl | 3 +- test/test_trees_and_forests.jl | 8 ++--- 52 files changed, 127 insertions(+), 214 deletions(-) delete mode 100644 src/GraphsExtensions/GraphsExtensions.jl rename src/{GraphsExtensions => graphsextensions}/abstractgraph.jl (99%) rename src/{GraphsExtensions => graphsextensions}/abstracttrees.jl (100%) rename src/{GraphsExtensions => graphsextensions}/arrange_edges.jl (100%) rename src/{GraphsExtensions => graphsextensions}/boundary.jl (100%) rename src/{GraphsExtensions => graphsextensions}/graphgenerators.jl (100%) rename src/{GraphsExtensions => graphsextensions}/neighbors.jl (100%) rename src/{GraphsExtensions => graphsextensions}/partitioning.jl (100%) rename src/{GraphsExtensions => graphsextensions}/shortestpaths.jl (100%) rename src/{GraphsExtensions => graphsextensions}/simplegraph.jl (100%) rename src/{GraphsExtensions => graphsextensions}/symrcm.jl (100%) rename src/{GraphsExtensions => graphsextensions}/trees_and_forests.jl (100%) diff --git a/docs/src/changelog.md b/docs/src/changelog.md index dc4a5050..4aa49558 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -98,6 +98,10 @@ and edges used internally. override these hooks rather than the Graphs.jl functions themselves, which means a subtype no longer needs its own `::Integer` disambiguator ([#187](https://github.com/ITensor/NamedGraphs.jl/pull/187)). +- The `GraphsExtensions` submodule is removed. Its contents are in `NamedGraphs` + directly, so `using NamedGraphs.GraphsExtensions: boundary_edges` becomes + `using NamedGraphs: boundary_edges` + ([#190](https://github.com/ITensor/NamedGraphs.jl/pull/190)). ### Non-breaking changes diff --git a/docs/src/dev_interface.md b/docs/src/dev_interface.md index a397497f..01464c35 100644 --- a/docs/src/dev_interface.md +++ b/docs/src/dev_interface.md @@ -30,6 +30,7 @@ decode_edge ## Graphs.jl interface extensions -```@docs; canonical=false -GraphsExtensions -``` +NamedGraphs also defines generic extensions of the Graphs.jl interface. Many of +them are written against `Graphs.AbstractGraph` rather than against named graphs, +so they work for any graph type, including `Graphs.SimpleGraph`. The rest need +vertices that carry names and are only defined for [`AbstractNamedGraph`](@ref). diff --git a/docs/src/reference.md b/docs/src/reference.md index 2d5e6cef..ed58d0cf 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -15,9 +15,3 @@ Modules = [NamedGraphs] ```@autodocs Modules = [NamedGraphs.PartitionedGraphs] ``` - -## GraphsExtensions - -```@autodocs -Modules = [NamedGraphs.GraphsExtensions] -``` diff --git a/examples/boundary.jl b/examples/boundary.jl index 895417c0..ad5a9391 100644 --- a/examples/boundary.jl +++ b/examples/boundary.jl @@ -1,6 +1,5 @@ -using NamedGraphs.GraphsExtensions: - boundary_vertices, inner_boundary_vertices, outer_boundary_vertices -using NamedGraphs: boundary_edges, named_grid +using NamedGraphs: boundary_edges, boundary_vertices, inner_boundary_vertices, named_grid, + outer_boundary_vertices g = named_grid((5, 5)) subgraph_vertices = [(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 2), (4, 3), (4, 4)] diff --git a/examples/mincut.jl b/examples/mincut.jl index a30fc105..97a348a6 100644 --- a/examples/mincut.jl +++ b/examples/mincut.jl @@ -1,6 +1,5 @@ using Graphs: path_graph -using NamedGraphs.GraphsExtensions: mincut_partitions -using NamedGraphs: NamedGraph +using NamedGraphs: NamedGraph, mincut_partitions g = NamedGraph(path_graph(4), ["A", "B", "C", "D"]) diff --git a/ext/NamedGraphsGraphsFlowsExt/NamedGraphsGraphsFlowsExt.jl b/ext/NamedGraphsGraphsFlowsExt/NamedGraphsGraphsFlowsExt.jl index ba96833f..e373f3a1 100644 --- a/ext/NamedGraphsGraphsFlowsExt/NamedGraphsGraphsFlowsExt.jl +++ b/ext/NamedGraphsGraphsFlowsExt/NamedGraphsGraphsFlowsExt.jl @@ -1,7 +1,6 @@ module NamedGraphsGraphsFlowsExt using Graphs: AbstractGraph, IsDirected using GraphsFlows: GraphsFlows -using NamedGraphs.GraphsExtensions: GraphsExtensions using NamedGraphs: NamedGraphs, AbstractNamedGraph, DefaultNamedCapacity, _symmetrize, decode_vertex, directed_graph, encode_dist_matrix, encode_vertex, encoded_graph using SimpleTraits: SimpleTraits, @traitfn @@ -44,7 +43,7 @@ end ) end -function GraphsExtensions.mincut_partitions( +function NamedGraphs.mincut_partitions( graph::AbstractGraph, source, target, diff --git a/ext/NamedGraphsKaHyParExt/NamedGraphsKaHyParExt.jl b/ext/NamedGraphsKaHyParExt/NamedGraphsKaHyParExt.jl index 814da567..f2f12e50 100644 --- a/ext/NamedGraphsKaHyParExt/NamedGraphsKaHyParExt.jl +++ b/ext/NamedGraphsKaHyParExt/NamedGraphsKaHyParExt.jl @@ -1,10 +1,10 @@ module NamedGraphsKaHyParExt using Graphs: AbstractSimpleGraph, incidence_matrix using KaHyPar: KaHyPar -using NamedGraphs.GraphsExtensions: @Backend_str, GraphsExtensions +using NamedGraphs: NamedGraphs, @Backend_str using SplitApplyCombine: groupfind -GraphsExtensions.set_partitioning_backend!(Backend"kahypar"()) +NamedGraphs.set_partitioning_backend!(Backend"kahypar"()) # KaHyPar configuration options # @@ -33,7 +33,7 @@ const KAHYPAR_ALGS = Dict( - :connectivity => "km1_kKaHyPar_sea20.ini" - imbalance::Number=0.03 """ -function GraphsExtensions.partition_vertices( +function NamedGraphs.partition_vertices( ::Backend"kahypar", g::AbstractSimpleGraph, npartitions::Integer; diff --git a/ext/NamedGraphsMetisExt/NamedGraphsMetisExt.jl b/ext/NamedGraphsMetisExt/NamedGraphsMetisExt.jl index 129c87b7..f36a8cf7 100644 --- a/ext/NamedGraphsMetisExt/NamedGraphsMetisExt.jl +++ b/ext/NamedGraphsMetisExt/NamedGraphsMetisExt.jl @@ -1,10 +1,10 @@ module NamedGraphsMetisExt using Graphs: AbstractSimpleGraph using Metis: Metis -using NamedGraphs.GraphsExtensions: @Backend_str, GraphsExtensions +using NamedGraphs: NamedGraphs, @Backend_str using SplitApplyCombine: groupfind -GraphsExtensions.set_partitioning_backend!(Backend"metis"()) +NamedGraphs.set_partitioning_backend!(Backend"metis"()) # Metis configuration options const METIS_ALGS = Dict(["kway" => :KWAY, "recursive" => :RECURSIVE]) @@ -18,7 +18,7 @@ The partition algorithm is defined by the `alg` keyword: - :KWAY: multilevel k-way partitioning - :RECURSIVE: multilevel recursive bisection """ -function GraphsExtensions.partition_vertices( +function NamedGraphs.partition_vertices( ::Backend"metis", g::AbstractSimpleGraph, npartitions::Integer; alg = "recursive", kwargs... ) diff --git a/ext/NamedGraphsSimpleGraphAlgorithmsExt/NamedGraphsSimpleGraphAlgorithmsExt.jl b/ext/NamedGraphsSimpleGraphAlgorithmsExt/NamedGraphsSimpleGraphAlgorithmsExt.jl index 5430bd3f..9e718798 100644 --- a/ext/NamedGraphsSimpleGraphAlgorithmsExt/NamedGraphsSimpleGraphAlgorithmsExt.jl +++ b/ext/NamedGraphsSimpleGraphAlgorithmsExt/NamedGraphsSimpleGraphAlgorithmsExt.jl @@ -1,6 +1,5 @@ module NamedGraphsSimpleGraphAlgorithmsExt using Graphs: AbstractGraph, dst, edges, edgetype, src, vertices -using NamedGraphs.GraphsExtensions: GraphsExtensions using NamedGraphs: AbstractNamedGraph, decode_vertex, encoded_graph using SimpleGraphAlgorithms: SimpleGraphAlgorithms using SimpleGraphs: UndirectedGraph, add! diff --git a/ext/NamedGraphsSymRCMExt/NamedGraphsSymRCMExt.jl b/ext/NamedGraphsSymRCMExt/NamedGraphsSymRCMExt.jl index 2a9c0d12..f7cff8c1 100644 --- a/ext/NamedGraphsSymRCMExt/NamedGraphsSymRCMExt.jl +++ b/ext/NamedGraphsSymRCMExt/NamedGraphsSymRCMExt.jl @@ -1,9 +1,9 @@ module NamedGraphsSymRCMExt using Graphs: AbstractGraph, adjacency_matrix -using NamedGraphs.GraphsExtensions: GraphsExtensions +using NamedGraphs: NamedGraphs using SymRCM: SymRCM -function GraphsExtensions.symrcm_perm(graph::AbstractGraph) +function NamedGraphs.symrcm_perm(graph::AbstractGraph) return SymRCM.symrcm(adjacency_matrix(graph)) end end diff --git a/src/GraphsExtensions/GraphsExtensions.jl b/src/GraphsExtensions/GraphsExtensions.jl deleted file mode 100644 index da8b504e..00000000 --- a/src/GraphsExtensions/GraphsExtensions.jl +++ /dev/null @@ -1,33 +0,0 @@ -""" - module GraphsExtensions - -Generic extensions of the Graphs.jl interface. - -Covers subgraphs, tree queries and traversals, neighborhoods and boundaries, -edge arranging, and vertex partitioning. Most of it is defined against -`Graphs.AbstractGraph` rather than against named graphs, so it works for any -graph type, including `Graphs.SimpleGraph`. -""" -module GraphsExtensions - -# These mirror the names `NamedGraphs` exports, so downstream never has to name -# this submodule. Everything else stays reachable by qualifying or by -# `using NamedGraphs.GraphsExtensions: name`, and moves here as it gets a -# docstring, which `Aqua.test_all(; undocumented_names = true)` requires. -export boundary_edges, - convert_vertextype, default_root_vertex, in_incident_edges, incident_edges, - is_leaf_vertex, leaf_vertices, post_order_dfs_edges, post_order_dfs_vertices, - similar_graph, subgraph, vertextype - -include("graphgenerators.jl") -include("abstractgraph.jl") -include("abstracttrees.jl") -include("boundary.jl") -include("neighbors.jl") -include("shortestpaths.jl") -include("symrcm.jl") -include("partitioning.jl") -include("trees_and_forests.jl") -include("simplegraph.jl") -include("arrange_edges.jl") -end diff --git a/src/NamedGraphs.jl b/src/NamedGraphs.jl index a4e5ab01..e7bd5bb7 100644 --- a/src/NamedGraphs.jl +++ b/src/NamedGraphs.jl @@ -33,7 +33,7 @@ export ⊔, AbstractNamedGraph, NamedDiGraph, NamedEdge, NamedGraph, similar_graph, spanning_forest, spanning_tree, subgraph, undirected_graph, vertextype if VERSION >= v"1.11.0-DEV.469" - eval(Meta.parse("public GraphsExtensions, PartitionedGraphs")) + eval(Meta.parse("public PartitionedGraphs")) # The encode and decode interface is what a new `AbstractNamedGraph` overloads, # so it is public rather than exported. # `to_graph_index` is an indexing extension point that graph and index types @@ -46,12 +46,17 @@ if VERSION >= v"1.11.0-DEV.469" end include("similartype.jl") -include("GraphsExtensions/GraphsExtensions.jl") -# The `GraphsExtensions` names re-exported below, listed here rather than relying -# on the per-file imports that happen to bring them into scope. -using .GraphsExtensions: boundary_edges, convert_vertextype, default_root_vertex, - in_incident_edges, incident_edges, is_leaf_vertex, leaf_vertices, post_order_dfs_edges, - post_order_dfs_vertices, similar_graph, subgraph, vertextype +include("graphsextensions/graphgenerators.jl") +include("graphsextensions/abstractgraph.jl") +include("graphsextensions/abstracttrees.jl") +include("graphsextensions/boundary.jl") +include("graphsextensions/neighbors.jl") +include("graphsextensions/shortestpaths.jl") +include("graphsextensions/symrcm.jl") +include("graphsextensions/partitioning.jl") +include("graphsextensions/trees_and_forests.jl") +include("graphsextensions/simplegraph.jl") +include("graphsextensions/arrange_edges.jl") include("utils.jl") include("abstractnamededge.jl") include("namededge.jl") diff --git a/src/PartitionedGraphs/abstractpartitionedgraph.jl b/src/PartitionedGraphs/abstractpartitionedgraph.jl index 55c7fae6..080c80ba 100644 --- a/src/PartitionedGraphs/abstractpartitionedgraph.jl +++ b/src/PartitionedGraphs/abstractpartitionedgraph.jl @@ -1,7 +1,5 @@ -using ..NamedGraphs.GraphsExtensions: - GraphsExtensions, convert_vertextype, not_implemented, subgraph -using ..NamedGraphs: - AbstractNamedGraph, NamedDiGraph, NamedGraph, NamedGraphs, get_graph_index +using ..NamedGraphs: AbstractNamedGraph, NamedDiGraph, NamedGraph, NamedGraphs, + convert_vertextype, get_graph_index, not_implemented, subgraph using Dictionaries: Dictionary using Graphs: Graphs, AbstractEdge, AbstractGraph, AbstractSimpleGraph, add_vertex!, dst, edgetype, has_vertex, is_directed, rem_vertex!, src, vertices @@ -133,7 +131,7 @@ of [`QuotientEdge`](@ref)s; the concrete type is not part of the interface, and the result may be a view into `graph`, so do not modify it or use it after mutating `graph`. -Keyword arguments are forwarded to `GraphsExtensions.boundary_edges`, in +Keyword arguments are forwarded to `boundary_edges`, in particular `dir`, which selects the edge direction to consider in a directed graph. """ @@ -263,10 +261,10 @@ Base.copy(::AbstractPartitionedGraph) = not_implemented() function unpartitioned_graph_type(::Type{<:AbstractPartitionedGraph}) return not_implemented() end -function GraphsExtensions.directed_graph_type(::Type{<:AbstractPartitionedGraph}) +function NamedGraphs.directed_graph_type(::Type{<:AbstractPartitionedGraph}) return not_implemented() end -function GraphsExtensions.undirected_graph_type(::Type{<:AbstractPartitionedGraph}) +function NamedGraphs.undirected_graph_type(::Type{<:AbstractPartitionedGraph}) return not_implemented() end diff --git a/src/PartitionedGraphs/partitionedgraph.jl b/src/PartitionedGraphs/partitionedgraph.jl index 9be56d4e..9ee3da71 100644 --- a/src/PartitionedGraphs/partitionedgraph.jl +++ b/src/PartitionedGraphs/partitionedgraph.jl @@ -1,6 +1,5 @@ -using ..NamedGraphs.GraphsExtensions: GraphsExtensions, boundary_edges, directed_graph_type, - is_self_loop, partition_vertices, undirected_graph_type, vertextype -using ..NamedGraphs: NamedEdge, NamedGraph, NamedGraphs +using ..NamedGraphs: NamedEdge, NamedGraph, NamedGraphs, boundary_edges, + directed_graph_type, is_self_loop, partition_vertices, undirected_graph_type, vertextype using Dictionaries: Dictionary using Graphs: AbstractEdge, AbstractGraph, add_edge!, dst, edges, edgetype, has_edge, induced_subgraph, src, vertices @@ -25,7 +24,7 @@ land in exactly one quotient vertex. Passing `partitioned_vertices` alone gives the discrete partitioning of an edgeless graph. Passing `graph` alone partitions with -`GraphsExtensions.partition_vertices`, which the keyword arguments go to: it +`partition_vertices`, which the keyword arguments go to: it needs either `npartitions` or `nvertices_per_partition`, and a backend such as Metis.jl loaded. @@ -249,7 +248,7 @@ function NamedGraphs.directed_graph(g::PartitionedGraph) dg = NamedGraphs.directed_graph(unpartitioned_graph(g)) return PartitionedGraph(dg, partitioned_vertices(g)) end -function GraphsExtensions.undirected_graph_type( +function NamedGraphs.undirected_graph_type( type::Type{<:PartitionedGraph{V, PV}} ) where {V, PV} UG = undirected_graph_type(unpartitioned_graph_type(type)) @@ -257,7 +256,7 @@ function GraphsExtensions.undirected_graph_type( P = fieldtype(type, :partitioned_vertices) return PartitionedGraph{V, PV, UG, QG, P} end -function GraphsExtensions.directed_graph_type( +function NamedGraphs.directed_graph_type( type::Type{<:PartitionedGraph{V, PV}} ) where {V, PV} DG = directed_graph_type(unpartitioned_graph_type(type)) diff --git a/src/PartitionedGraphs/quotientedge.jl b/src/PartitionedGraphs/quotientedge.jl index e4daba61..a0490056 100644 --- a/src/PartitionedGraphs/quotientedge.jl +++ b/src/PartitionedGraphs/quotientedge.jl @@ -1,6 +1,5 @@ -using ..NamedGraphs.GraphsExtensions: GraphsExtensions, not_implemented using ..NamedGraphs: AbstractEdges, AbstractNamedEdge, AbstractNamedGraph, Edges, - NamedGraphs, parent_graph_indices, rem_edges!, to_edges + NamedGraphs, not_implemented, parent_graph_indices, rem_edges!, to_edges using Graphs: Graphs, AbstractEdge, AbstractGraph, dst, has_edge, ne, src struct QuotientEdgeSlice{V, E, GI <: AbstractEdges{V, E}} <: AbstractEdges{V, E} @@ -177,7 +176,7 @@ Graphs.edgetype(::Type{<:QuotientEdgeEdge{V, E}}) where {V, E} = E Graphs.edgetype(::Type{<:QuotientEdgeEdge{V}}) where {V} = AbstractNamedEdge{V} Graphs.edgetype(::Type{<:QuotientEdgeEdge}) = AbstractNamedEdge -GraphsExtensions.vertextype(::Type{<:QuotientEdgeEdge{V, E}}) where {V, E} = V +NamedGraphs.vertextype(::Type{<:QuotientEdgeEdge{V, E}}) where {V, E} = V quotient_edgetype(::Type{<:QuotientEdgeEdge{V, E, QE}}) where {V, E, QE} = QE diff --git a/src/PartitionedGraphs/quotientvertex.jl b/src/PartitionedGraphs/quotientvertex.jl index 221ac406..513e3034 100644 --- a/src/PartitionedGraphs/quotientvertex.jl +++ b/src/PartitionedGraphs/quotientvertex.jl @@ -1,6 +1,5 @@ -using ..NamedGraphs.GraphsExtensions: GraphsExtensions, subgraph using ..NamedGraphs: AbstractNamedGraph, AbstractVertices, Edges, NamedGraphs, Vertices, - parent_graph_indices, to_graph_index, to_vertices + parent_graph_indices, subgraph, to_graph_index, to_vertices using Graphs: Graphs, AbstractGraph, induced_subgraph, nv struct QuotientVertexSlice{V, GI <: AbstractVertices{V}} <: AbstractVertices{V} @@ -128,8 +127,8 @@ function Base.getindex(qv::QuotientVertex, v::Vertices) return QuotientVertexVertices(qv.vertex, v.vertices) end -GraphsExtensions.vertextype(::Type{<:QuotientVertexVertex{V}}) where {V} = V -GraphsExtensions.vertextype(::Type{<:QuotientVertexVertex}) = Any +NamedGraphs.vertextype(::Type{<:QuotientVertexVertex{V}}) where {V} = V +NamedGraphs.vertextype(::Type{<:QuotientVertexVertex}) = Any quotient_vertextype(::Type{<:QuotientVertexVertex{V, QV}}) where {V, QV} = QV diff --git a/src/PartitionedGraphs/quotientview.jl b/src/PartitionedGraphs/quotientview.jl index 5e23d3b7..30a3506b 100644 --- a/src/PartitionedGraphs/quotientview.jl +++ b/src/PartitionedGraphs/quotientview.jl @@ -1,6 +1,5 @@ -using ..NamedGraphs: - NamedGraph, encoded_graph_type, induced_subgraph_from_vertices, similar_type -using .GraphsExtensions: directed_graph_type, undirected_graph_type +using ..NamedGraphs: NamedGraph, directed_graph_type, encoded_graph_type, + induced_subgraph_from_vertices, similar_type, undirected_graph_type using Graphs: AbstractGraph, edges, has_edge, rem_edge!, rem_vertex!, vertices """ @@ -71,10 +70,10 @@ function NamedGraphs.encoded_graph_type(type::Type{<:QuotientView}) return encoded_graph_type(quotient_graph_type(parent_graph_type(type))) end -function NamedGraphs.GraphsExtensions.directed_graph_type(type::Type{<:QuotientView}) +function NamedGraphs.directed_graph_type(type::Type{<:QuotientView}) return directed_graph_type(quotient_graph_type(parent_graph_type(type))) end -function NamedGraphs.GraphsExtensions.undirected_graph_type(type::Type{<:QuotientView}) +function NamedGraphs.undirected_graph_type(type::Type{<:QuotientView}) return undirected_graph_type(quotient_graph_type(parent_graph_type(type))) end diff --git a/src/abstractnamededge.jl b/src/abstractnamededge.jl index 8c9ca7da..6cc64d40 100644 --- a/src/abstractnamededge.jl +++ b/src/abstractnamededge.jl @@ -1,4 +1,3 @@ -using .GraphsExtensions: GraphsExtensions, convert_vertextype using Graphs: Graphs, AbstractEdge, dst, src abstract type AbstractNamedEdge{V} <: AbstractEdge{V} end @@ -10,12 +9,12 @@ Graphs.dst(e::AbstractNamedEdge) = not_implemented() AbstractNamedEdge(e::AbstractNamedEdge) = e -function GraphsExtensions.convert_vertextype( +function convert_vertextype( ::Type{V}, E::Type{<:AbstractNamedEdge{V}} ) where {V} return E end -function GraphsExtensions.convert_vertextype(::Type, E::Type{<:AbstractNamedEdge}) +function convert_vertextype(::Type, E::Type{<:AbstractNamedEdge}) return not_implemented() end @@ -39,15 +38,15 @@ function Base.:(==)(e1::AbstractNamedEdge, e2::AbstractNamedEdge) end Base.hash(e::AbstractNamedEdge, h::UInt) = hash(src(e), hash(dst(e), h)) -# TODO: Define generic version in `GraphsExtensions`. -# TODO: Define generic `set_vertices` in `GraphsExtensions`. +# TODO: Define generic version. +# TODO: Define generic `set_vertices`. set_src(e::AbstractNamedEdge, src) = set_vertices(e, src, dst(e)) -# TODO: Define generic version in `GraphsExtensions`. -# TODO: Define generic `set_vertices` in `GraphsExtensions`. +# TODO: Define generic version. +# TODO: Define generic `set_vertices`. set_dst(e::AbstractNamedEdge, dst) = set_vertices(e, src(e), dst) function rename_vertices(f::Function, e::AbstractNamedEdge) - # TODO: Define generic `set_vertices` in `GraphsExtensions`. + # TODO: Define generic `set_vertices`. return set_vertices(e, f(src(e)), f(dst(e))) end diff --git a/src/abstractnamedgraph.jl b/src/abstractnamedgraph.jl index b5f221b3..dbe4748c 100644 --- a/src/abstractnamedgraph.jl +++ b/src/abstractnamedgraph.jl @@ -1,5 +1,3 @@ -using .GraphsExtensions: GraphsExtensions, all_edges, directed_graph_type, incident_edges, - partition_vertices, similar_graph, subgraph, undirected_graph_type using Dictionaries: Dictionary, set! using Graphs: Graphs, AbstractGraph, AbstractSimpleGraph, IsDirected, SimpleDiGraph, SimpleEdge, SimpleGraph, a_star, add_edge!, adjacency_matrix, bfs_parents, blockdiag, @@ -180,7 +178,7 @@ julia> [decode_vertex(g, c) for c in 1:nv(g)] Graphs.vertices(graph::AbstractNamedGraph) = NamedVerticesView(graph) # TODO: Is this a good definition? Maybe make it generic to any graph? -function GraphsExtensions.permute_vertices(graph::AbstractNamedGraph, permutation) +function permute_vertices(graph::AbstractNamedGraph, permutation) return subgraph(graph, map(c -> decode_vertex(graph, c), permutation)) end @@ -192,8 +190,8 @@ end # In terms of `encoded_graph_type` # is_directed(::Type{<:AbstractNamedGraph}) = not_implemented() -GraphsExtensions.convert_vertextype(::Type{V}, g::AbstractNamedGraph{V}) where {V} = g -function GraphsExtensions.convert_vertextype(vertextype::Type, graph::AbstractNamedGraph) +convert_vertextype(::Type{V}, g::AbstractNamedGraph{V}) where {V} = g +function convert_vertextype(vertextype::Type, graph::AbstractNamedGraph) new_vertices = map(c -> decode_vertex(graph, c), vertices(encoded_graph(graph))) return namedgraph(copy(encoded_graph(graph)), convert(Vector{vertextype}, new_vertices)) end @@ -491,7 +489,7 @@ function Graphs.mincut(graph::AbstractNamedGraph, distmx::AbstractMatrix{<:Numbe end # TODO: Make this more generic? -function GraphsExtensions.partition_vertices( +function partition_vertices( graph::AbstractNamedGraph; npartitions = nothing, nvertices_per_partition = nothing, kwargs... ) diff --git a/src/decorate.jl b/src/decorate.jl index 7c735925..74247bcb 100644 --- a/src/decorate.jl +++ b/src/decorate.jl @@ -1,8 +1,7 @@ -using .GraphsExtensions: GraphsExtensions using Graphs.SimpleGraphs: SimpleGraph using Graphs: add_edge!, dst, edges, neighbors, rem_edge!, rem_vertex!, src, vertices -function GraphsExtensions.decorate_graph_edges( +function decorate_graph_edges( g::AbstractNamedGraph; edge_map::Function = Returns(NamedGraph(1)) ) g_dec = copy(g) @@ -18,7 +17,7 @@ function GraphsExtensions.decorate_graph_edges( return g_dec end -function GraphsExtensions.decorate_graph_vertices( +function decorate_graph_vertices( g::AbstractNamedGraph; vertex_map::Function = Returns(NamedGraph(1)) ) g_dec = copy(g) diff --git a/src/distance.jl b/src/distance.jl index 938ceb38..af03c06a 100644 --- a/src/distance.jl +++ b/src/distance.jl @@ -1,4 +1,3 @@ -using .GraphsExtensions: eccentricities using Graphs: Graphs, dijkstra_shortest_paths, weights function eccentricity_namedgraph(graph::AbstractNamedGraph, vertex, distmx) diff --git a/src/distances_and_capacities.jl b/src/distances_and_capacities.jl index 72f604e0..ab91ca09 100644 --- a/src/distances_and_capacities.jl +++ b/src/distances_and_capacities.jl @@ -4,12 +4,12 @@ using LinearAlgebra: Symmetric using SimpleTraits: SimpleTraits, @traitfn, Not using SparseArrays: sparse, spzeros -# TODO: Move to `GraphsExtensions`. +# TODO: Generalize to any `Graphs.AbstractGraph`. function _symmetrize(dist::AbstractMatrix) return sparse(Symmetric(dist)) end -# TODO: Move to `GraphsExtensions`. +# TODO: Generalize to any `Graphs.AbstractGraph`. function _symmetrize(dist) symmetrized_dist = copy(dist) for k in keys(dist) @@ -18,7 +18,7 @@ function _symmetrize(dist) return symmetrized_dist end -# TODO: Move to `GraphsExtensions`. +# TODO: Generalize to any `Graphs.AbstractGraph`. function _symmetrize(dist::AbstractDictionary) symmetrized_dist = copy(dist) for k in keys(dist) diff --git a/src/graph_unions.jl b/src/graph_unions.jl index 667107c1..20469d9f 100644 --- a/src/graph_unions.jl +++ b/src/graph_unions.jl @@ -2,8 +2,8 @@ using Dictionaries: Dictionary, dictionary using Graphs: AbstractGraph # Renaming vertices and taking disjoint unions only make sense for graphs whose -# vertices are names, so they live here rather than in `GraphsExtensions`, which -# holds extensions that apply to any `Graphs.AbstractGraph`. +# vertices are names, unlike the Graphs.jl extensions here that apply to any +# `Graphs.AbstractGraph`. """ rename_vertices(f, graph::AbstractGraph) diff --git a/src/GraphsExtensions/abstractgraph.jl b/src/graphsextensions/abstractgraph.jl similarity index 99% rename from src/GraphsExtensions/abstractgraph.jl rename to src/graphsextensions/abstractgraph.jl index 2d83f72e..135867c3 100644 --- a/src/GraphsExtensions/abstractgraph.jl +++ b/src/graphsextensions/abstractgraph.jl @@ -7,8 +7,6 @@ using Graphs: Graphs, AbstractEdge, AbstractGraph, AbstractSimpleGraph, IsDirect using SimpleTraits: SimpleTraits, @traitfn, Not using SplitApplyCombine: groupfind -not_implemented() = error("Not implemented") - is_self_loop(e::AbstractEdge) = src(e) == dst(e) is_self_loop(e::Pair) = first(e) == last(e) diff --git a/src/GraphsExtensions/abstracttrees.jl b/src/graphsextensions/abstracttrees.jl similarity index 100% rename from src/GraphsExtensions/abstracttrees.jl rename to src/graphsextensions/abstracttrees.jl diff --git a/src/GraphsExtensions/arrange_edges.jl b/src/graphsextensions/arrange_edges.jl similarity index 100% rename from src/GraphsExtensions/arrange_edges.jl rename to src/graphsextensions/arrange_edges.jl diff --git a/src/GraphsExtensions/boundary.jl b/src/graphsextensions/boundary.jl similarity index 100% rename from src/GraphsExtensions/boundary.jl rename to src/graphsextensions/boundary.jl diff --git a/src/GraphsExtensions/graphgenerators.jl b/src/graphsextensions/graphgenerators.jl similarity index 100% rename from src/GraphsExtensions/graphgenerators.jl rename to src/graphsextensions/graphgenerators.jl diff --git a/src/GraphsExtensions/neighbors.jl b/src/graphsextensions/neighbors.jl similarity index 100% rename from src/GraphsExtensions/neighbors.jl rename to src/graphsextensions/neighbors.jl diff --git a/src/GraphsExtensions/partitioning.jl b/src/graphsextensions/partitioning.jl similarity index 100% rename from src/GraphsExtensions/partitioning.jl rename to src/graphsextensions/partitioning.jl diff --git a/src/GraphsExtensions/shortestpaths.jl b/src/graphsextensions/shortestpaths.jl similarity index 100% rename from src/GraphsExtensions/shortestpaths.jl rename to src/graphsextensions/shortestpaths.jl diff --git a/src/GraphsExtensions/simplegraph.jl b/src/graphsextensions/simplegraph.jl similarity index 100% rename from src/GraphsExtensions/simplegraph.jl rename to src/graphsextensions/simplegraph.jl diff --git a/src/GraphsExtensions/symrcm.jl b/src/graphsextensions/symrcm.jl similarity index 100% rename from src/GraphsExtensions/symrcm.jl rename to src/graphsextensions/symrcm.jl diff --git a/src/GraphsExtensions/trees_and_forests.jl b/src/graphsextensions/trees_and_forests.jl similarity index 100% rename from src/GraphsExtensions/trees_and_forests.jl rename to src/graphsextensions/trees_and_forests.jl diff --git a/src/indicesviews.jl b/src/indicesviews.jl index 66f6e68a..7a9a62b6 100644 --- a/src/indicesviews.jl +++ b/src/indicesviews.jl @@ -1,4 +1,3 @@ -using .GraphsExtensions: vertextype using Dictionaries: Dictionaries, AbstractDictionary, AbstractIndices using Graphs: AbstractEdge, AbstractEdgeIter, AbstractGraph, Edge, edges, edgetype, has_edge, has_vertex, ne, nv diff --git a/src/namededge.jl b/src/namededge.jl index 5f0cacf4..80d90142 100644 --- a/src/namededge.jl +++ b/src/namededge.jl @@ -1,4 +1,3 @@ -using .GraphsExtensions: GraphsExtensions using Graphs: Graphs """ @@ -16,7 +15,7 @@ end NamedEdge(src::V, dst::V) where {V} = NamedEdge{V}(src, dst) NamedEdge(src, dst) = NamedEdge{promote_type(typeof(src), typeof(dst))}(src, dst) -function GraphsExtensions.convert_vertextype(vertextype::Type, ::Type{<:NamedEdge}) +function convert_vertextype(vertextype::Type, ::Type{<:NamedEdge}) return NamedEdge{vertextype} end @@ -38,5 +37,5 @@ NamedEdge(p::Pair) = NamedEdge(p...) NamedEdge{V}(p::Pair) where {V} = NamedEdge{V}(p...) NamedEdge{V}(p::Tuple) where {V} = NamedEdge{V}(p...) -# TODO: Define generic `set_vertices` in `GraphsExtensions`. +# TODO: Define generic `set_vertices`. set_vertices(e::NamedEdge, src, dst) = NamedEdge(src, dst) diff --git a/src/namedgraph.jl b/src/namedgraph.jl index c758a3be..2469282b 100644 --- a/src/namedgraph.jl +++ b/src/namedgraph.jl @@ -1,4 +1,3 @@ -using .GraphsExtensions: GraphsExtensions, similar_graph, similar_simplegraph, vertextype using Dictionaries: Dictionary using Graphs.SimpleGraphs: AbstractSimpleGraph, SimpleDiGraph, SimpleGraph using Graphs: Graphs, AbstractGraph, IsDirected, add_edge!, add_vertex!, edgetype, has_edge, @@ -186,10 +185,10 @@ function rename_vertices(f::Function, g::AbstractSimpleGraph) ) end -GraphsExtensions.directed_graph_type(::Type{<:NamedGraph{V}}) where {V} = NamedDiGraph{V} -GraphsExtensions.directed_graph_type(::Type{<:NamedDiGraph{V}}) where {V} = NamedDiGraph{V} -GraphsExtensions.undirected_graph_type(::Type{<:NamedGraph{V}}) where {V} = NamedGraph{V} -GraphsExtensions.undirected_graph_type(::Type{<:NamedDiGraph{V}}) where {V} = NamedGraph{V} +directed_graph_type(::Type{<:NamedGraph{V}}) where {V} = NamedDiGraph{V} +directed_graph_type(::Type{<:NamedDiGraph{V}}) where {V} = NamedDiGraph{V} +undirected_graph_type(::Type{<:NamedGraph{V}}) where {V} = NamedGraph{V} +undirected_graph_type(::Type{<:NamedDiGraph{V}}) where {V} = NamedGraph{V} function edge_subgraph_namedgraph(graph::NamedDiGraph, edgelist) vs = unique(vcat(src.(edgelist), dst.(edgelist))) diff --git a/src/namedgraphgenerators.jl b/src/namedgraphgenerators.jl index cb55b2f8..aa00600e 100644 --- a/src/namedgraphgenerators.jl +++ b/src/namedgraphgenerators.jl @@ -1,21 +1,15 @@ -using .GraphsExtensions: comb_tree using Graphs.SimpleGraphs: AbstractSimpleGraph using Graphs: IsDirected, bfs_tree, binary_tree, cycle_graph, grid, inneighbors, - merge_vertices, nv, outneighbors, path_digraph, path_graph, rem_vertex!, rem_vertices! + merge_vertices, nv, path_digraph, path_graph, rem_vertex!, rem_vertices! using SimpleTraits: SimpleTraits, @traitfn, Not ## TODO: Bring this back in some form? -## TODO: Move to `GraphsExtensions`? +## TODO: Generalize to any `Graphs.AbstractGraph`? ## @traitfn function parent(tree::AbstractSimpleGraph::IsDirected, v::Integer) ## return only(inneighbors(tree, v)) ## end -## TODO: Move to `GraphsExtensions`? -@traitfn function children(tree::AbstractSimpleGraph::IsDirected, v::Integer) - return outneighbors(tree, v) -end - -## TODO: Move to `GraphsExtensions`? +## TODO: Generalize to any `Graphs.AbstractGraph`? @traitfn function set_named_vertices!( vertex_names::AbstractVector, tree::AbstractSimpleGraph::IsDirected, @@ -23,7 +17,7 @@ end named_parent; child_name = identity ) - simple_children = children(tree, simple_parent) + simple_children = child_vertices(tree, simple_parent) for n in 1:length(simple_children) simple_child = simple_children[n] named_child = [named_parent; child_name(n)] diff --git a/src/similar_graph.jl b/src/similar_graph.jl index 60cb1eba..4e51d0c0 100644 --- a/src/similar_graph.jl +++ b/src/similar_graph.jl @@ -1,16 +1,15 @@ -using .GraphsExtensions: similar_dataless_graph, similar_graph, similar_simplegraph using Graphs: edges, vertices using SimpleTraits: SimpleTraits, @traitfn, Not # =================================== `similar_graph` ==================================== # -function GraphsExtensions.similar_graph(graph::AbstractNamedGraph) +function similar_graph(graph::AbstractNamedGraph) newgraph = similar_graph(graph, vertices(graph)) add_edges!(newgraph, edges(graph)) return newgraph end -function GraphsExtensions.similar_graph(graph::AbstractNamedGraph, vertices) +function similar_graph(graph::AbstractNamedGraph, vertices) return similar_namedgraph(graph, vertices) end @@ -34,7 +33,7 @@ similar_namedgraph(g::AbstractGraph, ::Base.OneTo) = similar_graph(g, collect(ve # Passing a type as a first argument attempts to call a constructor. Should be overloaded # if the constructor doesnt exist for a given `AbstractGraph` concrete type. -function GraphsExtensions.similar_graph(T::Type{<:AbstractNamedGraph}) +function similar_graph(T::Type{<:AbstractNamedGraph}) return similar_graph(T, vertextype(T)[]) end @@ -42,13 +41,13 @@ end # This function behaves much the same as `similar_graph`, but should strictly return a # a similar graph type that has no notion of data (in the abstract sense). -function GraphsExtensions.similar_dataless_graph(graph::AbstractNamedGraph) +function similar_dataless_graph(graph::AbstractNamedGraph) dataless_graph = similar_dataless_graph(graph, vertices(graph)) add_edges!(dataless_graph, edges(graph)) return dataless_graph end -function GraphsExtensions.similar_dataless_graph(graph::AbstractNamedGraph, vertices) +function similar_dataless_graph(graph::AbstractNamedGraph, vertices) return similar_dataless_namedgraph(graph, vertices) end @@ -67,5 +66,5 @@ end end function similar_dataless_namedgraph(graph::AbstractNamedGraph, nv::Int) - return GraphsExtensions.similar_dataless_simplegraph(graph, nv) + return similar_dataless_simplegraph(graph, nv) end diff --git a/src/trees_and_forests.jl b/src/trees_and_forests.jl index 5614b6f9..17a8e4c6 100644 --- a/src/trees_and_forests.jl +++ b/src/trees_and_forests.jl @@ -1,6 +1,3 @@ -using .GraphsExtensions: BFS, DFS, RandomBFS, default_root_vertex, - default_spanning_tree_alg, post_order_dfs_edges, random_bfs_tree, - similar_dataless_graph, subgraph using Graphs: IsDirected, bfs_tree, connected_components, dfs_tree, edges, edgetype using SimpleTraits: SimpleTraits, @traitfn, Not diff --git a/test/test_abstractgraph.jl b/test/test_abstractgraph.jl index 0c192bba..c155581e 100644 --- a/test/test_abstractgraph.jl +++ b/test/test_abstractgraph.jl @@ -1,8 +1,7 @@ using Graphs: binary_tree, dfs_tree, edgetype, grid, path_graph -using NamedGraphs.GraphsExtensions: - comb_tree, edge_path, is_path_graph, pre_order_dfs_vertices, vertex_path -using NamedGraphs: is_leaf_vertex, leaf_vertices, named_binary_tree, named_comb_tree, - named_grid, named_path_graph, post_order_dfs_vertices +using NamedGraphs: comb_tree, edge_path, is_leaf_vertex, is_path_graph, leaf_vertices, + named_binary_tree, named_comb_tree, named_grid, named_path_graph, + post_order_dfs_vertices, pre_order_dfs_vertices, vertex_path using Test: @test, @testset @testset "Tree graph paths" begin diff --git a/test/test_abstractnamedgraph.jl b/test/test_abstractnamedgraph.jl index e8a1317c..a4f30edc 100644 --- a/test/test_abstractnamedgraph.jl +++ b/test/test_abstractnamedgraph.jl @@ -5,10 +5,10 @@ using Graphs: Graphs, AbstractGraph, DiGraph, Graph, SimpleDiGraph, SimpleEdge, floyd_warshall_shortest_paths, grid, has_edge, has_path, has_vertex, johnson_shortest_paths, ne, nv, path_graph, rem_edge!, spfa_shortest_paths, steiner_tree, vertices, weights, yen_k_shortest_paths -using NamedGraphs.GraphsExtensions: GraphsExtensions, eccentricities, similar_dataless_graph using NamedGraphs: NamedGraphs, AbstractNamedGraph, NamedDiGraph, NamedEdge, NamedGraph, - add_vertices, edgeless_graph, empty_graph, encoded_graph, named_grid, named_path_graph, - rem_vertices, rename_vertices, similar_graph, subgraph + add_vertices, eccentricities, edgeless_graph, empty_graph, encoded_graph, named_grid, + named_path_graph, rem_vertices, rename_vertices, similar_dataless_graph, similar_graph, + subgraph using Test: @test, @test_throws, @testset # A callable that is not a `Function`, to check that heuristics are not diff --git a/test/test_cycles.jl b/test/test_cycles.jl index ab481fcc..0a1d0648 100644 --- a/test/test_cycles.jl +++ b/test/test_cycles.jl @@ -1,7 +1,6 @@ using Graphs: edges, ne, vertices -using NamedGraphs.GraphsExtensions: degree, is_connected -using NamedGraphs: edge_subgraph, leafless_edge_induced_subgraphs, named_comb_tree, - named_grid, named_hexagonal_lattice_graph, rem_vertex +using NamedGraphs: degree, edge_subgraph, is_connected, leafless_edge_induced_subgraphs, + named_comb_tree, named_grid, named_hexagonal_lattice_graph, rem_vertex using Test: @test, @testset @testset "leafless_edge_induced_subgraphs" begin diff --git a/test/test_exports.jl b/test/test_exports.jl index ef3ad8fe..3272bb80 100644 --- a/test/test_exports.jl +++ b/test/test_exports.jl @@ -55,7 +55,6 @@ using Test: @test, @testset # `names` includes `public` names as well as exported ones. public_names = if VERSION >= v"1.11.0-DEV.469" [ - :GraphsExtensions, :PartitionedGraphs, :decode_edge, :decode_vertex, @@ -69,27 +68,6 @@ using Test: @test, @testset end @test issetequal(names(NamedGraphs), [exports; public_names]) end - @testset "GraphsExtensions" begin - exports = [ - :GraphsExtensions, - :boundary_edges, - :convert_vertextype, - :default_root_vertex, - :in_incident_edges, - :incident_edges, - :is_leaf_vertex, - :leaf_vertices, - :post_order_dfs_edges, - :post_order_dfs_vertices, - :similar_graph, - :subgraph, - :vertextype, - ] - @test issetequal(names(NamedGraphs.GraphsExtensions), exports) - # Unlike `PartitionedGraphs`, these are also exported from `NamedGraphs`, so - # downstream does not have to name the submodule. - @test issubset(setdiff(exports, [:GraphsExtensions]), names(NamedGraphs)) - end @testset "PartitionedGraphs" begin exports = [ :AbstractPartitionedGraph, diff --git a/test/test_graphdecoration.jl b/test/test_graphdecoration.jl index b142ab28..b5e76ebd 100644 --- a/test/test_graphdecoration.jl +++ b/test/test_graphdecoration.jl @@ -1,6 +1,6 @@ using Graphs: a_star, edges, vertices -using NamedGraphs.GraphsExtensions: decorate_graph_edges, decorate_graph_vertices -using NamedGraphs: named_grid, named_hexagonal_lattice_graph +using NamedGraphs: + decorate_graph_edges, decorate_graph_vertices, named_grid, named_hexagonal_lattice_graph using Test: @test, @testset @testset "Decorated Graphs" begin diff --git a/test/test_graphsextensions.jl b/test/test_graphsextensions.jl index 56275626..38f7cc38 100644 --- a/test/test_graphsextensions.jl +++ b/test/test_graphsextensions.jl @@ -5,19 +5,18 @@ using Graphs.SimpleGraphs: SimpleDiGraph, SimpleEdge, SimpleGraph, binary_tree, cycle_digraph, cycle_graph, grid, path_digraph, path_graph using Graphs: AbstractGraph, add_edge!, add_vertex!, dst, edges, edgetype, has_edge, inneighbors, is_cyclic, is_directed, ne, nv, outneighbors, rem_edge!, src, vertices -using NamedGraphs.GraphsExtensions: TreeGraph, all_edges, arrange_edge, arranged_edges, - binary_arborescence, child_edges, child_vertices, degrees, directed_graph_type, - distance_to_leaves, has_edges, has_leaf_neighbor, has_vertices, indegrees, - is_arborescence, is_arranged, is_binary_arborescence, is_cycle_graph, is_ditree, - is_edge_arranged, is_leaf_edge, is_path_graph, is_root_vertex, is_rooted, is_self_loop, - minimum_distance_to_leaves, next_nearest_neighbors, non_leaf_edges, outdegrees, - permute_vertices, root_vertex, similar_dataless_graph, tree_graph_node, - undirected_graph_type, vertices_at_distance -using NamedGraphs: NamedDiGraph, NamedEdge, NamedGraph, add_edge, add_edges, add_edges!, - convert_vertextype, directed_graph, disjoint_union, forest_cover_edge_sequence, - incident_edges, is_leaf_vertex, leaf_vertices, named_path_digraph, named_path_graph, - rem_edge, rem_edges, rem_edges!, rename_vertices, similar_graph, subgraph, - undirected_graph, vertextype, ⊔ +using NamedGraphs: NamedDiGraph, NamedEdge, NamedGraph, TreeGraph, add_edge, add_edges, + add_edges!, all_edges, arrange_edge, arranged_edges, binary_arborescence, child_edges, + child_vertices, convert_vertextype, degrees, directed_graph, directed_graph_type, + disjoint_union, distance_to_leaves, forest_cover_edge_sequence, has_edges, + has_leaf_neighbor, has_vertices, incident_edges, indegrees, is_arborescence, + is_arranged, is_binary_arborescence, is_cycle_graph, is_ditree, is_edge_arranged, + is_leaf_edge, is_leaf_vertex, is_path_graph, is_root_vertex, is_rooted, is_self_loop, + leaf_vertices, minimum_distance_to_leaves, named_path_digraph, named_path_graph, + next_nearest_neighbors, non_leaf_edges, outdegrees, permute_vertices, rem_edge, + rem_edges, rem_edges!, rename_vertices, root_vertex, similar_dataless_graph, + similar_graph, subgraph, tree_graph_node, undirected_graph, undirected_graph_type, + vertextype, vertices_at_distance, ⊔ using Test: @test, @test_broken, @test_throws, @testset # TODO: Still need to test: @@ -36,7 +35,7 @@ using Test: @test, @test_broken, @test_throws, @testset # - decorate_graph_vertices # - random_bfs_tree -@testset "NamedGraphs.GraphsExtensions" begin +@testset "Graphs.jl extensions" begin # has_vertices g = path_graph(4) diff --git a/test/test_namedgraph.jl b/test/test_namedgraph.jl index 653ac414..6ea11153 100644 --- a/test/test_namedgraph.jl +++ b/test/test_namedgraph.jl @@ -11,14 +11,13 @@ using Graphs: Edge, a_star, add_edge!, add_vertex!, adjacency_matrix, prim_mst, radius, rem_edge!, rem_vertex!, spfa_shortest_paths, src, steiner_tree, topological_sort_by_dfs, vertices, yen_k_shortest_paths, Δ, δ using GraphsFlows: GraphsFlows -using NamedGraphs.GraphsExtensions: GraphsExtensions, boundary_vertices, degrees, - dijkstra_mst, dijkstra_parents, dijkstra_tree, eccentricities, has_vertices, indegrees, - inner_boundary_vertices, mincut_partitions, outdegrees, outer_boundary_vertices, - permute_vertices, symrcm_perm, symrcm_permute using NamedGraphs: AbstractNamedEdge, NamedDiGraph, NamedEdge, NamedGraph, Vertices, - boundary_edges, convert_vertextype, edge_subgraph, incident_edges, named_binary_tree, - named_grid, named_hexagonal_lattice_graph, named_path_graph, rename_vertices, subgraph, - vertextype, ⊔ + boundary_edges, boundary_vertices, convert_vertextype, degrees, dijkstra_mst, + dijkstra_parents, dijkstra_tree, eccentricities, edge_subgraph, has_vertices, + incident_edges, indegrees, inner_boundary_vertices, mincut_partitions, + named_binary_tree, named_grid, named_hexagonal_lattice_graph, named_path_graph, + outdegrees, outer_boundary_vertices, permute_vertices, rename_vertices, subgraph, + symrcm_perm, symrcm_permute, vertextype, ⊔ using SymRCM: SymRCM using Test: @test, @test_broken, @testset diff --git a/test/test_namedgraphgenerators.jl b/test/test_namedgraphgenerators.jl index 9def6046..a68311f5 100644 --- a/test/test_namedgraphgenerators.jl +++ b/test/test_namedgraphgenerators.jl @@ -1,9 +1,9 @@ using Graphs: a_star, add_edge!, add_vertex!, degree, dst, edges, edgetype, has_edge, has_vertex, is_directed, ne, neighbors, nv, rem_edge!, rem_vertex!, src, vertices -using NamedGraphs.GraphsExtensions: is_cycle_graph using NamedGraphs: NamedEdge, NamedGridGraph, decode_vertex, encode_vertex, grid_ndims, - grid_size, is_directed_grid, ishypertorus, named_binary_tree, named_cycle_graph, - named_grid, named_hexagonal_lattice_graph, named_triangular_lattice_graph, vertextype + grid_size, is_cycle_graph, is_directed_grid, ishypertorus, named_binary_tree, + named_cycle_graph, named_grid, named_hexagonal_lattice_graph, + named_triangular_lattice_graph, vertextype using Test: @test, @test_throws, @testset @testset "Named Graph Generators" begin diff --git a/test/test_partitionedgraph.jl b/test/test_partitionedgraph.jl index 858333e9..f19619e5 100644 --- a/test/test_partitionedgraph.jl +++ b/test/test_partitionedgraph.jl @@ -3,7 +3,6 @@ using Graphs: Graphs, AbstractGraph, a_star, add_vertices!, center, connected_co diameter, edges, has_edge, has_vertex, is_connected, is_directed, is_tree, ne, neighbors, nv, radius, random_regular_graph, rem_vertex!, vertices using Metis: Metis -using NamedGraphs.GraphsExtensions: edgetype, is_path_graph, is_self_loop using NamedGraphs.PartitionedGraphs: AbstractPartitionedGraph, PartitionedGraph, PartitionedGraphs, PartitionedView, QuotientEdge, QuotientEdgeEdge, QuotientEdgeEdges, QuotientEdgeSlice, QuotientEdges, QuotientEdgesEdges, QuotientVertex, @@ -14,9 +13,10 @@ using NamedGraphs.PartitionedGraphs: AbstractPartitionedGraph, PartitionedGraph, quotientvertices, rem_quotientvertex!, to_quotient_index, unpartition, unpartitioned_graph using NamedGraphs: NamedGraphs, Edges, NamedEdge, NamedGraph, Vertices, add_edges!, - boundary_edges, default_root_vertex, forest_cover, named_comb_tree, named_grid, - named_triangular_lattice_graph, parent_graph_indices, spanning_forest, spanning_tree, - subgraph, to_graph_index, vertextype + boundary_edges, default_root_vertex, edgetype, forest_cover, is_path_graph, + is_self_loop, named_comb_tree, named_grid, named_triangular_lattice_graph, + parent_graph_indices, spanning_forest, spanning_tree, subgraph, to_graph_index, + vertextype using Pkg: Pkg using Test: @test, @test_throws, @testset diff --git a/test/test_random_bfs_tree.jl b/test/test_random_bfs_tree.jl index 8c6070c3..d0df1511 100644 --- a/test/test_random_bfs_tree.jl +++ b/test/test_random_bfs_tree.jl @@ -1,6 +1,5 @@ using Graphs: bfs_tree, edges, is_connected, vertices -using NamedGraphs.GraphsExtensions: random_bfs_tree -using NamedGraphs: named_grid +using NamedGraphs: named_grid, random_bfs_tree using Random: Random using Test: @test, @testset diff --git a/test/test_staticgraphs.jl b/test/test_staticgraphs.jl index dbbf86f7..cd6ed253 100644 --- a/test/test_staticgraphs.jl +++ b/test/test_staticgraphs.jl @@ -1,6 +1,5 @@ using Graphs: ne, neighbors, nv, vertices -using NamedGraphs.GraphsExtensions: comb_tree -using NamedGraphs: named_comb_tree +using NamedGraphs: comb_tree, named_comb_tree using Random: Random using Test: @test, @testset diff --git a/test/test_trees_and_forests.jl b/test/test_trees_and_forests.jl index e62b93a1..13a7605f 100644 --- a/test/test_trees_and_forests.jl +++ b/test/test_trees_and_forests.jl @@ -1,7 +1,7 @@ using Graphs: connected_components, edges, is_tree, vertices -using NamedGraphs.GraphsExtensions: GraphsExtensions, all_edges -using NamedGraphs: NamedGraph, Vertices, forest_cover, named_comb_tree, named_grid, - named_hexagonal_lattice_graph, named_triangular_lattice_graph, spanning_tree, vertextype +using NamedGraphs: BFS, DFS, NamedGraph, RandomBFS, Vertices, all_edges, forest_cover, + named_comb_tree, named_grid, named_hexagonal_lattice_graph, + named_triangular_lattice_graph, spanning_tree, vertextype using Test: @test, @testset gs = [ @@ -12,7 +12,7 @@ gs = [ ("Square lattice", named_grid((10, 10))), ("Triangular Grid", named_triangular_lattice_graph(5, 5; periodic = true)), ] -algs = (GraphsExtensions.BFS(), GraphsExtensions.DFS(), GraphsExtensions.RandomBFS()) +algs = (BFS(), DFS(), RandomBFS()) @testset "Test Spanning Trees $g_string, $alg" for (g_string, g) in gs, alg in algs s_tree = spanning_tree(g; alg) From 7394793af0956128bdc58a53c97b0a9170f149d3 Mon Sep 17 00:00:00 2001 From: Matthew Fishman Date: Fri, 28 Aug 2026 16:39:50 -0400 Subject: [PATCH 2/2] Correct the comment on the partitioning backend default The default is never populated automatically, but setting it with `set_partitioning_backend!` works, so the comment saying the state was dead in practice was wrong. --- src/graphsextensions/partitioning.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/graphsextensions/partitioning.jl b/src/graphsextensions/partitioning.jl index 5a5601e3..e78942ce 100644 --- a/src/graphsextensions/partitioning.jl +++ b/src/graphsextensions/partitioning.jl @@ -13,12 +13,12 @@ macro Backend_str(s) return :(Backend{$(Expr(:quote, Symbol(s)))}) end -# Process-wide default backend for `partition_vertices`, and dead in practice: -# the `ext/` packages call `set_partitioning_backend!` at module top level, which -# runs at precompile time and writes to a `Ref` in this package's image, so the -# write is not replayed when the cached extension loads. It stays `missing` even -# after `using Metis`, which is why `partition_vertices` needs an explicit -# `backend`. +# Process-wide default backend for `partition_vertices`. Setting it with +# `set_partitioning_backend!` works, but nothing populates it automatically: the +# `ext/` packages call the setter at module top level, which runs at precompile +# time and writes to a `Ref` in this package's image, so the write is not replayed +# when the cached extension loads. It is still `missing` after `using Metis`, so a +# caller either sets the backend first or passes `backend` explicitly. const CURRENT_PARTITIONING_BACKEND = Ref{Union{Missing, Backend}}(missing) current_partitioning_backend() = CURRENT_PARTITIONING_BACKEND[]