diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9497b4..3434c3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: julia --project=docs -e ' using Documenter: DocMeta, doctest using SimpleValueGraphs - DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, LightGraphs, Random); recursive=true) + DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, Graphs, Random); recursive=true) doctest(SimpleValueGraphs)' # change MYPACKAGE to the name of your package - run: julia --project=docs docs/make.jl env: diff --git a/Project.toml b/Project.toml index 9921cd0..d58addf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,11 +1,11 @@ name = "SimpleValueGraphs" uuid = "b43c691f-cac2-5415-8122-396fe16a49fc" authors = ["Simon Schoelly "] -version = "0.3.2" +version = "0.4.0" [deps] DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Requires = "ae029012-a4dd-5104-9daa-d747884805df" SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" @@ -15,8 +15,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] DataStructures = "0.18.9" -LightGraphs = "1.3" +Graphs = "1.4.1" Requires = "1.0" SimpleTraits = "0.9.3" -SimpleWeightedGraphs = "1.1.1" +SimpleWeightedGraphs = "1.2" julia = "1.5" diff --git a/README.md b/README.md index fcaccf3..f2ca4ed 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![codecov](https://codecov.io/gh/simonschoelly/SimpleValueGraphs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/simonschoelly/SimpleValueGraphs.jl) [![](https://img.shields.io/badge/chat-Zulip%23graphs-yellow)](https://julialang.zulipchat.com/#narrow/stream/228745-graphs) -SimpleValueGraphs is as [LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl) compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides: +SimpleValueGraphs is a [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides: - an abstract interface for graphs with metadata - concrete implementations of mutable graphs with metadata @@ -26,12 +26,12 @@ Compared to [MetaGraphs.jl](https://github.com/JuliaGraphs/MetaGraphs.jl) it has ```julia using SimpleValueGraphs -using LightGraphs: smallgraph +using Graphs: smallgraph using Plots using GraphRecipes: graphplot using Colors: RGB, Color -# Load a LightGraphs.SimpleGraph +# Load a Graphs.SimpleGraph gs = smallgraph(:house) # Convert to a ValGraph with vertex and edge values @@ -58,25 +58,25 @@ graphplot(gv; ## Benchmarks -This is a comparison of running `LightGraphs.dijkstra_shortest_paths` on the [egonets-Facebook](https://snap.stanford.edu/data/egonets-Facebook.html) graph for multiple graph types. +This is a comparison of running `Graphs.dijkstra_shortest_paths` on the [egonets-Facebook](https://snap.stanford.edu/data/egonets-Facebook.html) graph for multiple graph types. | graph type | time (ms) | | ------------------------------------------------- | --------- | -| LightGraphs.SimpleGraph + Matrix weights | 6.5 | -| LightGraphs.SimpleGraph + SparseMatrixCSC weights | 11.4 | +| Graphs.SimpleGraph + Matrix weights | 6.5 | +| Graphs.SimpleGraph + SparseMatrixCSC weights | 11.4 | | SimpleWeightedGraphs.SimpleWeightedGraph | 11.7 | | MetaGraphs.MetaGraph | 141.9 | | SimpleValueGraphs.ValGraph | 12.4 | -Currently a lot of LightGraphs algorithm do not optimally work with graphs that store edge metadata +Currently a lot of Graphs.jl algorithms do not optimally work with graphs that store edge metadata internally. The next benchmark is an optimized version of the same algorithm that can be found in `SimpleValueGraphs.Experimental.dijkstra_shortests_pasts`. Clearly, this is a huge improvement for `ValGraph` and `SimpleWeightedGraph`. | graph type | time (ms) | | ------------------------------------------------- | --------- | -| LightGraphs.SimpleGraph + Matrix weights | 6.8 | -| LightGraphs.SimpleGraph + SparseMatrixCSC weights | 10.8 | +| Graphs.SimpleGraph + Matrix weights | 6.8 | +| Graphs.SimpleGraph + SparseMatrixCSC weights | 10.8 | | SimpleWeightedGraphs.SimpleWeightedGraph | 2.9 | | MetaGraphs.MetaGraph | 147.3 | | SimpleValueGraphs.ValGraph | 3.1 | diff --git a/benchmarks/Project.toml b/benchmarks/Project.toml index 00ceaa1..95756d8 100644 --- a/benchmarks/Project.toml +++ b/benchmarks/Project.toml @@ -1,6 +1,6 @@ [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" SNAPDatasets = "fc66bc1b-447b-53fc-8f09-bc9cfb0b0c10" SimpleValueGraphs = "b43c691f-cac2-5415-8122-396fe16a49fc" diff --git a/benchmarks/benchmarks.jl b/benchmarks/benchmarks.jl index 739abc1..b2667c7 100644 --- a/benchmarks/benchmarks.jl +++ b/benchmarks/benchmarks.jl @@ -1,5 +1,5 @@ using BenchmarkTools -using SimpleValueGraphs, LightGraphs +using SimpleValueGraphs, Graphs using SimpleWeightedGraphs, MetaGraphs using SNAPDatasets: loadsnap, snap_graphs using SparseArrays diff --git a/docs/Project.toml b/docs/Project.toml index ba48566..2affdd3 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,5 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SimpleValueGraphs = "b43c691f-cac2-5415-8122-396fe16a49fc" diff --git a/docs/make.jl b/docs/make.jl index 6d1bc97..f580af7 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,6 +1,6 @@ using Documenter, SimpleValueGraphs -DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, LightGraphs, Random); recursive=true) +DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, Graphs, Random); recursive=true) makedocs( sitename = "SimpleValueGraphs.jl", authors = "Simon Schoelly", diff --git a/docs/src/custom-valuegraph-types.md b/docs/src/custom-valuegraph-types.md index 04be95b..462d572 100644 --- a/docs/src/custom-valuegraph-types.md +++ b/docs/src/custom-valuegraph-types.md @@ -3,14 +3,14 @@ While this package provides some concrete graph types, one is often interested in creating their own graph types. This section will explain how one can create a custom graph type that will work well with the methods from as package as well as the ones from -[LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl) +[Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) ## The AbstractValGraph type All value graphs should be subtypes of *AbstractValGraph* that has the signature ```julia - AbstractValGraph{V <: Integer, V_VALS, E_VALS, G_VALS} <: LightGraphs.AbstractGraph{V} + AbstractValGraph{V <: Integer, V_VALS, E_VALS, G_VALS} <: Graphs.AbstractGraph{V} ``` where the parameters have the following meaning: - `V` is the type used for indexing vertices, called the *eltype* of the graph. Should @@ -29,8 +29,8 @@ MyGraphType{W} <: AbstractValGraph{Int, Tuple{}, Tuple{Int, W}, Tuple{}} is a graph type that has neither vertex nor graph values and two edge values, one of them of type `Int` and the other of type `W`. -As a subtype of `LightGraphs.AbstractGraph`, an `AbstractValGraph` should implement the -[methods required by LightGraphs](https://github.com/JuliaGraphs/LightGraphs.jl) as well as some +As a subtype of `Graphs.AbstractGraph`, an `AbstractValGraph` should implement the +[methods required by Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) as well as some other methods. Luckily a lot of the methods required for `AbstractGraph` already have a default implementation, so the number of necessary methods is actually much shorter. diff --git a/docs/src/graphtypes.md b/docs/src/graphtypes.md index 8e5fd99..5a77b13 100644 --- a/docs/src/graphtypes.md +++ b/docs/src/graphtypes.md @@ -8,7 +8,7 @@ and three concrete implementations. The abstract type `AbstractValGraph` denotes a graph that can have multiple vertex and edge values. It has the signature ```julia - AbstractValGraph{V, V_VALS, E_VALS} <: LightGraphs.AbstractGraph{V} + AbstractValGraph{V, V_VALS, E_VALS} <: Graphs.AbstractGraph{V} ``` where the parameters have the following meaning: - `V` is the type used for indexing vertices, called the *eltype* of the graph. Should @@ -116,7 +116,7 @@ Graphs without any values an be created with ```julia ValGraph{V = Int32}(n) ``` -where `n` is the number of vertices. One notable difference to LightGraphs is that the +where `n` is the number of vertices. One notable difference to Graphs.jl is that the eltype is not bases on the type of `n` but is always taken from the parameter `V`. ```julia @@ -185,9 +185,9 @@ julia> g2 = ValDiGraph{Int8}(4; edge value types: () ``` -#### Graph from LightGraphs SimpleGraphs +#### Graph from Graphs.jl SimpleGraphs -One can also initialize a graph from a LightGraphs `SimpleGraph` or `SimpleDiGraph`. If +One can also initialize a graph from a Graphs.jl `SimpleGraph` or `SimpleDiGraph`. If edge values are specified (with the `edgeval_types` keyword) we also need an initializer for edge values. We do that by using the `edgeval_init` keyword argument which can be either `undef` or a function `(s, d) -> values` that takes a source and target vertex and @@ -199,7 +199,7 @@ Furthermore, if the eltype is not specified as a parameter, it is taken from the graph. ```julia -julia> using LightGraphs: smallgraph, PathDiGraph +julia> using Graphs.jl: smallgraph, PathDiGraph julia> g_simple = smallgraph(:house) {5, 6} undirected simple Int64 graph diff --git a/docs/src/matrices.md b/docs/src/matrices.md index dbc812d..2b8b937 100644 --- a/docs/src/matrices.md +++ b/docs/src/matrices.md @@ -6,12 +6,12 @@ that contain the topology of the graph. ## Adjacency matrices The `adjacency_matrix` function creates an adjacency matrix from a value graph . In contrast -to LightGraphs, this is just a immutable *matrix view* of the graph, i.e if the graph +to Graphs.jl, this is just a immutable *matrix view* of the graph, i.e if the graph changes, then so does this matrix. Therefore to get a mutable adjacency matrix one has to convert it before to some other matrix type. It is also possible to use the constructor `AdjacencyMatrix` to create a view of any -`LightGraphs.AbstractGraph`. +`Graphs.AbstractGraph`. ```julia julia> g1 = SimpleValueGraphs.swissmetro_graph(); @@ -65,8 +65,8 @@ julia> ValMatrix(g, :b, nothing) "xyz" nothing nothing ``` -One can also use the `LightGraphs.weights` function to obtain this matrix. If the graph -does not have any edge values, this returns a `LightGraphs.DefaultDistance` instead. +One can also use the `Graphs.weights` function to obtain this matrix. If the graph +does not have any edge values, this returns a `Graphs.DefaultDistance` instead. ```julia julia> weights(g1, :a) diff --git a/examples/Project.toml b/examples/Project.toml index 2422bd9..9f38353 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,6 +1,6 @@ [deps] GraphRecipes = "bd48cda9-67a9-57be-86fa-5b3c104eda73" -LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781" SimpleValueGraphs = "b43c691f-cac2-5415-8122-396fe16a49fc" diff --git a/examples/custom-graph-type.jl b/examples/custom-graph-type.jl index 4ec4db6..d28bf56 100644 --- a/examples/custom-graph-type.jl +++ b/examples/custom-graph-type.jl @@ -16,8 +16,8 @@ begin using SparseArrays # We are going to test our new packages with some functions - # from LightGraphs and GraphsRecipes - using LightGraphs + # from Graphs.jl and GraphsRecipes + using Graphs using GraphRecipes, Plots pyplot() # gr backend has issues showing edge labels so we use pyplot instead end @@ -46,7 +46,7 @@ where * `E_VALS` are the types of the edge values * `G_VALS` are the types of the edge values -As this type of `LightGraphs.AbstractGraph`, it can also be used with LightGraphs functions as long as we correctly implement the `AbstractGraph` interface. +As this type of `Graphs.AbstractGraph`, it can also be used with Graphs functions as long as we correctly implement the `AbstractGraph` interface. In our case the vertex type will be `Int` as this type is also used for indexing rows and columns in a matrix. @@ -73,7 +73,7 @@ md""" ## Implementing the AbstractValGraph interface -To be able to do anything meaningful with that graph, we have to implement the interface for `LightGraphs.AbstractGraph` as well as the interface for `SimpleGraphs.AbstractValGraph`. Luckily, SimpleValueGraphs provides already some sensible defaults (that can be overriden for performance or other reasons) for a lot of LightGraphs functions so that what we will have to implement is less than is usually required by LightGraphs. Nevertheless we need to implement the following functions: +To be able to do anything meaningful with that graph, we have to implement the interface for `Graphs.AbstractGraph` as well as the interface for `SimpleGraphs.AbstractValGraph`. Luckily, SimpleValueGraphs provides already some sensible defaults (that can be overriden for performance or other reasons) for a lot of Graphs.jl functions so that what we will have to implement is less than is usually required by Graphs.jl. Nevertheless we need to implement the following functions: * `nv(::GraphView)` * `is_directed(::Type{<:GraphView})` @@ -134,7 +134,7 @@ SimpleValueGraphs.get_edgeval(g::GraphView, u, v, key::Integer) = weight=g.matri # ╔═╡ ed96451c-5596-11eb-1c39-8b28c0e661af md""" ##### zero -This function is a bit of an anomaly and should in my opinion not be part of the LightGraphs interface. It is also rarely used in LightGraphs, so it might not be a very big issue to omit it. Nevertheless we implement it here for the sake of completeness. +This function is a bit of an anomaly and should in my opinion not be part of the Graphs.jl interface. It is also rarely used in Graphs.jl, so it might not be a very big issue to omit it. Nevertheless we implement it here for the sake of completeness. `zero(G)` should create a graph with zero vertices, given a graph type. We do this here by trying to create a matrix of size (0, 0) and the correct matrix type, and then wrap a `GraphView` around it: """ @@ -235,7 +235,7 @@ md""" ### Shortest paths -Let's use some functions from LightGraphs to find the shortest path from vertex `2` to `5`: +Let's use some functions from Graphs.jl to find the shortest path from vertex `2` to `5`: """ # ╔═╡ 1147357a-2095-11eb-224e-61ad831db786 diff --git a/src/Experimental.jl b/src/Experimental.jl index c463494..746abe6 100644 --- a/src/Experimental.jl +++ b/src/Experimental.jl @@ -6,7 +6,7 @@ This module contains experimental stuff that does not respect SemVer """ module Experimental -using LightGraphs: AbstractGraph, weights, nv, vertices, outneighbors, DijkstraState, DefaultDistance +using Graphs: AbstractGraph, weights, nv, vertices, outneighbors, DijkstraState, DefaultDistance using DataStructures: PriorityQueue, dequeue! using SimpleValueGraphs: ValGraph, edgevals_type, outedgevals using SimpleWeightedGraphs: SimpleWeightedGraph, weighttype diff --git a/src/SimpleValueGraphs.jl b/src/SimpleValueGraphs.jl index 95dbcf5..ced3935 100644 --- a/src/SimpleValueGraphs.jl +++ b/src/SimpleValueGraphs.jl @@ -1,17 +1,16 @@ module SimpleValueGraphs -using LightGraphs: AbstractGraph, AbstractEdgeIter, AbstractEdge, num_self_loops +using Graphs: AbstractGraph, AbstractEdgeIter, AbstractEdge, num_self_loops -using LightGraphs.SimpleGraphs: AbstractSimpleGraph, AbstractSimpleEdge, +using Graphs.SimpleGraphs: AbstractSimpleGraph, AbstractSimpleEdge, SimpleGraph, SimpleDiGraph, SimpleEdge, IsDirected using Base: OneTo -import LightGraphs -const LG = LightGraphs +import Graphs -import LightGraphs: +import Graphs: nv, ne, is_directed, eltype, vertices, add_vertex!, rem_vertex!, has_vertex, edgetype, edges, src, dst, reverse, @@ -67,7 +66,7 @@ export AdjacencyMatrix, ValMatrix, - # overridden methods from LightGraphs + # overridden methods from Graphs.jl nv, ne, is_directed, diff --git a/src/abstractvaluegraph.jl b/src/abstractvaluegraph.jl index d108443..99e31b1 100644 --- a/src/abstractvaluegraph.jl +++ b/src/abstractvaluegraph.jl @@ -39,11 +39,11 @@ ZeroGraphValGraph{V, V_VALS, E_VALS} = AbstractValGraph{V, V_VALS, E_VALS, <: Ab # eltype # ------------------------------------------------------ -LG.eltype(::Type{<:AbstractValGraph{V}}) where {V} = V +Graphs.eltype(::Type{<:AbstractValGraph{V}}) where {V} = V # This should not be necessary, as Base implements `eltype(x) = eltype(typeof(x))` -# but unfortunately LightGraphs redefines `eltype(::AbstractGraph)` as not defined -LG.eltype(g::AbstractValGraph) = eltype(typeof(g)) +# but unfortunately Graphs.jl redefines `eltype(::AbstractGraph)` as not defined +Graphs.eltype(g::AbstractValGraph) = eltype(typeof(g)) # ------------------------------------------------------ @@ -214,12 +214,12 @@ end # ====================================================== -# Partial default implementation of LightGraphs interface +# Partial default implementation of Graphs.jl interface # ====================================================== -LG.vertices(g::AbstractValGraph) = OneTo{eltype(g)}(nv(g)) +Graphs.vertices(g::AbstractValGraph) = OneTo{eltype(g)}(nv(g)) -LG.has_vertex(g::AbstractValGraph, v) = v ∈ vertices(g) +Graphs.has_vertex(g::AbstractValGraph, v) = v ∈ vertices(g) """ edges(g::AbstractValGraph[, key]) @@ -227,17 +227,17 @@ LG.has_vertex(g::AbstractValGraph, v) = v ∈ vertices(g) Return the edges of `g`. By default add no edge values but when `key=:` then add edge values. """ -LG.edges(g::AbstractValGraph, key=nothing) = ValEdgeIter(g, key) +Graphs.edges(g::AbstractValGraph, key=nothing) = ValEdgeIter(g, key) -LG.edgetype(g::AbstractValGraph) = eltype(edges(g)) +Graphs.edgetype(g::AbstractValGraph) = eltype(edges(g)) -LG.ne(g::AbstractValGraph) = length(edges(g)) +Graphs.ne(g::AbstractValGraph) = length(edges(g)) # TODO a Base.Generator would be better here, but it causes problems with sort. Maybe # add a custom iterator -LG.outneighbors(g::AbstractValGraph, u) = [v for v ∈ vertices(g) if has_edge(g, u, v)] +Graphs.outneighbors(g::AbstractValGraph, u) = [v for v ∈ vertices(g) if has_edge(g, u, v)] -LG.inneighbors(g::AbstractValGraph, v) = is_directed(g) ? [u for u ∈ vertices(g) if has_edge(g, u, v)] : outneighbors(g, v) +Graphs.inneighbors(g::AbstractValGraph, v) = is_directed(g) ? [u for u ∈ vertices(g) if has_edge(g, u, v)] : outneighbors(g, v) # ====================================================== @@ -264,9 +264,9 @@ If the edge already exists, return `false` but still change the edge values. """ function add_edge! end -LG.add_edge!(g::ZeroEdgeValGraph, s, d) = add_edge!(g, s, d, ()) +Graphs.add_edge!(g::ZeroEdgeValGraph, s, d) = add_edge!(g, s, d, ()) -LG.add_edge!(g::OneEdgeValGraph, s, d; val) = add_edge!(g, s, d, tuple(val)) +Graphs.add_edge!(g::OneEdgeValGraph, s, d; val) = add_edge!(g, s, d, tuple(val)) # ----------------------------------------------------- @@ -288,9 +288,9 @@ Return `true` if the vertex was added successfully, otherwise return `false`. """ function add_vertex! end -LG.add_vertex!(g::ZeroVertexValGraph) = add_vertex!(g, ()) +Graphs.add_vertex!(g::ZeroVertexValGraph) = add_vertex!(g, ()) -LG.add_vertex!(g::OneVertexValGraph; val) = add_vertex!(g, tuple(val)) +Graphs.add_vertex!(g::OneVertexValGraph; val) = add_vertex!(g, tuple(val)) # ====================================================== diff --git a/src/integrations/SimpleGraphs.jl b/src/integrations/SimpleGraphs.jl index 059d69b..1f4d0eb 100644 --- a/src/integrations/SimpleGraphs.jl +++ b/src/integrations/SimpleGraphs.jl @@ -1,5 +1,5 @@ -# This file contains value graph constructors from LightGraphs simple graphs. +# This file contains value graph constructors from Graphs.jl simple graphs. """ ValGraph{V, V_VALS, E_VALS}( @@ -20,7 +20,7 @@ Construct a `ValGraph` with the same structure as `g`. # Arguments -- `g`: A `LightGraphs.SimpleGraph` +- `g`: A `Graphs.SimpleGraph` # Keywords - `vertexval_init`: How the vertex values of this graph should be initialized. @@ -111,7 +111,7 @@ ValGraph(g::SimpleGraph; kwargs...) = ValGraph{eltype(g)}(g; kwargs...) Construct a `ValOutDiGraph` with the same structure as `g`. # Arguments -- `g`: A `LightGraphs.SimpleDiGraph` +- `g`: A `Graphs.SimpleDiGraph` # Keywords - `vertexval_init`: How the vertex values of this graph should be initialized. @@ -195,7 +195,7 @@ ValOutDiGraph(g::SimpleDiGraph; kwargs...) = ValOutDiGraph{eltype(g)}(g; kwargs. Construct a `ValDiGraph` with the same structure as `g`. # Arguments -- `g`: A `LightGraphs.SimpleDiGraph` +- `g`: A `Graphs.SimpleDiGraph` # Keywords - `vertexval_init`: How the vertex values of this graph should be initialized. diff --git a/src/matrices.jl b/src/matrices.jl index 55b51a7..b6cb05f 100644 --- a/src/matrices.jl +++ b/src/matrices.jl @@ -78,7 +78,7 @@ julia> adjacency_matrix(gv) 1 0 0 0 ``` """ -LG.adjacency_matrix(g::AbstractValGraph) = AdjacencyMatrix(g) +Graphs.adjacency_matrix(g::AbstractValGraph) = AdjacencyMatrix(g) ## --------------------------------------------------------------- ## LinearAlgebra @@ -373,14 +373,14 @@ without any edge values. """ function weights end -function LG.weights(g::AbstractValGraph, key; zerovalue=zero(edgevals_type(g, key))) +function Graphs.weights(g::AbstractValGraph, key; zerovalue=zero(edgevals_type(g, key))) return ValMatrix(g, key, zerovalue) end -function LG.weights(g::AbstractValGraph; kwargs...) +function Graphs.weights(g::AbstractValGraph; kwargs...) - g isa ZeroEdgeValGraph && return LG.DefaultDistance(nv(g)) + g isa ZeroEdgeValGraph && return Graphs.DefaultDistance(nv(g)) g isa OneEdgeValGraph && return weights(g, 1; kwargs...) throw(ArgumentError("g has more than one edge value key. Must specify key.")) diff --git a/src/valueedge.jl b/src/valueedge.jl index 1636674..6cc7427 100644 --- a/src/valueedge.jl +++ b/src/valueedge.jl @@ -110,8 +110,8 @@ ValDiEdge{V}(s, d, values=()) where {V} = ValDiEdge{V, typeof(values)}(s, d, val # src & dst # ------------------------------------------------------ -LG.src(e::AbstractValEdge) = e.src -LG.dst(e::AbstractValEdge) = e.dst +Graphs.src(e::AbstractValEdge) = e.src +Graphs.dst(e::AbstractValEdge) = e.dst # ------------------------------------------------------ @@ -163,17 +163,17 @@ get_edgeval(e::AbstractValEdge, key) = e.values[key] # reverse # ------------------------------------------------------ -LG.reverse(e::ValEdge) = e -LG.reverse(e::ValDiEdge) = ValDiEdge(dst(e), src(e), get_edgeval(e, :)) +Graphs.reverse(e::ValEdge) = e +Graphs.reverse(e::ValDiEdge) = ValDiEdge(dst(e), src(e), get_edgeval(e, :)) # ------------------------------------------------------ # is_directed # ------------------------------------------------------ -LG.is_directed(::Type{<:ValEdge}) = false -LG.is_directed(::Type{<:ValDiEdge}) = true -LG.is_directed(e::AbstractValEdge) = is_directed(typeof(e)) +Graphs.is_directed(::Type{<:ValEdge}) = false +Graphs.is_directed(::Type{<:ValDiEdge}) = true +Graphs.is_directed(e::AbstractValEdge) = is_directed(typeof(e)) # ------------------------------------------------------ # == diff --git a/src/valuegraph.jl b/src/valuegraph.jl index e87dd46..ec4b9a1 100644 --- a/src/valuegraph.jl +++ b/src/valuegraph.jl @@ -391,23 +391,23 @@ ValOutDiGraph(g::ValGraph) = ValOutDiGraph{eltype(g)}(g) # nv # ------------------------------------------------------ -LG.nv(g::ValGraph) = eltype(g)(length(g.fadjlist)) -LG.nv(g::ValOutDiGraph) = eltype(g)(length(g.fadjlist)) -LG.nv(g::ValDiGraph) = eltype(g)(length(g.fadjlist)) +Graphs.nv(g::ValGraph) = eltype(g)(length(g.fadjlist)) +Graphs.nv(g::ValOutDiGraph) = eltype(g)(length(g.fadjlist)) +Graphs.nv(g::ValDiGraph) = eltype(g)(length(g.fadjlist)) # ------------------------------------------------------ # ne # ------------------------------------------------------ -LG.ne(g::ValGraph) = g.ne -LG.ne(g::ValDiGraph) = g.ne -LG.ne(g::ValOutDiGraph) = g.ne +Graphs.ne(g::ValGraph) = g.ne +Graphs.ne(g::ValDiGraph) = g.ne +Graphs.ne(g::ValOutDiGraph) = g.ne # ------------------------------------------------------ # add_edge! # ------------------------------------------------------ -function LG.add_edge!(g::ValGraph, s::Integer, d::Integer, values) +function Graphs.add_edge!(g::ValGraph, s::Integer, d::Integer, values) E_VALS = edgevals_type(g) values = convert_to_tuple(E_VALS, values) @@ -439,7 +439,7 @@ function LG.add_edge!(g::ValGraph, s::Integer, d::Integer, values) return true # edge successfully added end -function LG.add_edge!(g::ValOutDiGraph, s::Integer, d::Integer, values) +function Graphs.add_edge!(g::ValOutDiGraph, s::Integer, d::Integer, values) E_VALS = edgevals_type(g) values = convert_to_tuple(E_VALS, values) @@ -460,7 +460,7 @@ function LG.add_edge!(g::ValOutDiGraph, s::Integer, d::Integer, values) return true # edge successfully added end -function LG.add_edge!(g::ValDiGraph, s::Integer, d::Integer, values) +function Graphs.add_edge!(g::ValDiGraph, s::Integer, d::Integer, values) E_VALS = edgevals_type(g) values = convert_to_tuple(E_VALS, values) @@ -490,7 +490,7 @@ end # rem_edge! # ------------------------------------------------------ -function LG.rem_edge!(g::ValGraph, s::Integer, d::Integer) +function Graphs.rem_edge!(g::ValGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds edgevals = g.edgevals @@ -511,7 +511,7 @@ function LG.rem_edge!(g::ValGraph, s::Integer, d::Integer) return true end -function LG.rem_edge!(g::ValOutDiGraph, s::Integer, d::Integer) +function Graphs.rem_edge!(g::ValOutDiGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds edgevals = g.edgevals @@ -526,7 +526,7 @@ function LG.rem_edge!(g::ValOutDiGraph, s::Integer, d::Integer) end -function LG.rem_edge!(g::ValDiGraph, s::Integer, d::Integer) +function Graphs.rem_edge!(g::ValDiGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds @inbounds list = g.fadjlist[s] @@ -549,7 +549,7 @@ end # add_vertex! # ------------------------------------------------------ -function LG.add_vertex!(g::ValGraph, values) +function Graphs.add_vertex!(g::ValGraph, values) V = eltype(g) V_VALS = vertexvals_type(g) @@ -573,7 +573,7 @@ function LG.add_vertex!(g::ValGraph, values) return true end -function LG.add_vertex!(g::ValOutDiGraph, values) +function Graphs.add_vertex!(g::ValOutDiGraph, values) V = eltype(g) V_VALS = vertexvals_type(g) @@ -597,7 +597,7 @@ function LG.add_vertex!(g::ValOutDiGraph, values) return true end -function LG.add_vertex!(g::ValDiGraph, values) +function Graphs.add_vertex!(g::ValDiGraph, values) V = eltype(g) V_VALS = vertexvals_type(g) @@ -634,7 +634,7 @@ end # has_edge # ------------------------------------------------------ -function LG.has_edge(g::ValGraph, s::Integer, d::Integer) +function Graphs.has_edge(g::ValGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds @inbounds list_s = g.fadjlist[s] @@ -643,18 +643,18 @@ function LG.has_edge(g::ValGraph, s::Integer, d::Integer) d = s list_s = list_d end - return LightGraphs.insorted(d, list_s) + return Graphs.insorted(d, list_s) end -function LG.has_edge(g::ValOutDiGraph, s::Integer, d::Integer) +function Graphs.has_edge(g::ValOutDiGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds @inbounds list_s = g.fadjlist[s] - return LightGraphs.insorted(d, list_s) + return Graphs.insorted(d, list_s) end -function LG.has_edge(g::ValDiGraph, s::Integer, d::Integer) +function Graphs.has_edge(g::ValDiGraph, s::Integer, d::Integer) verts = vertices(g) (s in verts && d in verts) || return false # edge out of bounds @inbounds list_fadj = g.fadjlist[s] @@ -663,7 +663,7 @@ function LG.has_edge(g::ValDiGraph, s::Integer, d::Integer) d = s list_fadj = list_badj end - return LightGraphs.insorted(d, list_fadj) + return Graphs.insorted(d, list_fadj) end # ------------------------------------------------------ @@ -1198,24 +1198,24 @@ end # is_directed # ------------------------------------------------------ -LG.is_directed(::Type{<:ValGraph}) = false -LG.is_directed(::Type{<:ValOutDiGraph}) = true -LG.is_directed(::Type{<:ValDiGraph}) = true +Graphs.is_directed(::Type{<:ValGraph}) = false +Graphs.is_directed(::Type{<:ValOutDiGraph}) = true +Graphs.is_directed(::Type{<:ValDiGraph}) = true # ------------------------------------------------------ # outneighbors # ------------------------------------------------------ -LG.outneighbors(g::ValGraph, v::Integer) = g.fadjlist[v] -LG.outneighbors(g::ValDiGraph, v::Integer) = g.fadjlist[v] -LG.outneighbors(g::ValOutDiGraph, v::Integer) = g.fadjlist[v] +Graphs.outneighbors(g::ValGraph, v::Integer) = g.fadjlist[v] +Graphs.outneighbors(g::ValDiGraph, v::Integer) = g.fadjlist[v] +Graphs.outneighbors(g::ValOutDiGraph, v::Integer) = g.fadjlist[v] # ------------------------------------------------------ # inneighbors # ------------------------------------------------------ -LG.inneighbors(g::ValGraph, v::Integer) = outneighbors(g, v) -LG.inneighbors(g::ValDiGraph, v::Integer) = g.badjlist[v] +Graphs.inneighbors(g::ValGraph, v::Integer) = outneighbors(g, v) +Graphs.inneighbors(g::ValDiGraph, v::Integer) = g.badjlist[v] # ------------------------------------------------------ # outedgevals diff --git a/test/matrices.jl b/test/matrices.jl index fb1e7ae..c4f5aeb 100644 --- a/test/matrices.jl +++ b/test/matrices.jl @@ -1,7 +1,7 @@ using LinearAlgebra: ishermitian, issymmetric, mul! using SparseArrays: AbstractSparseMatrix using SimpleValueGraphs: OneEdgeValGraph -using LightGraphs: DefaultDistance +using Graphs: DefaultDistance @testset "matrices" begin diff --git a/test/runtests.jl b/test/runtests.jl index 068b2cd..93bcfa6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using LightGraphs +using Graphs using SimpleValueGraphs using Test