Skip to content

Commit

Permalink
Support AttributeGraphs v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
filchristou committed Jun 29, 2023
1 parent 73f28da commit ed46a04
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 127 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NestedGraphs"
uuid = "03c36417-ddab-428a-818d-5359aee292ef"
authors = ["fchrstou <[email protected]> and contributors"]
version = "0.2"
version = "0.2.1"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -22,7 +22,7 @@ AbstractTrees = "0.4"
DocStringExtensions = "0.9"
Graphs = "1"
MetaGraphs = "0.7"
AttributeGraphs = "0.2"
AttributeGraphs = "0.3"
SimpleTraits = "0.9"

julia = "1.9"
Expand Down
46 changes: 23 additions & 23 deletions ext/NestedGraphsAttributeGraphsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ module NestedGraphsAttributeGraphsExt
using NestedGraphs, Graphs, DocStringExtensions
using AttributeGraphs

import AttributeGraphs: AbstractAttibuteGraph, addgraphattr!, remgraphattr!, addvertexattr!, remvertexattr!, addedgeattr!, remedgeattr!, graph_attr, vertex_attr, edge_attr, addvertex!, remvertex!, addedge!, remedge!, hasedgeattr, hasgraphattr, hasvertexattr, getgraphattr, getvertexattr, getedgeattr
import AttributeGraphs: AbstractAttributeGraph, addgraphattr!, remgraphattr!, addvertexattr!, remvertexattr!, addedgeattr!, remedgeattr!, graph_attr, vertex_attr, edge_attr, addvertex!, remvertex!, addedge!, remedge!, hasedgeattr, hasgraphattr, hasvertexattr, getgraphattr, getvertexattr, getedgeattr

getgraphattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttibuteGraph} = getgraphattr(NestedGraphs.getgraph(ag), k)
getvertexattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttibuteGraph} = getvertexattr(NestedGraphs.getgraph(ag), k)
getedgeattr(ag::NestedGraph{T,G}, args...) where {T<:Integer,G<:AbstractAttibuteGraph} = getedgeattr(NestedGraphs.getgraph(ag), args...)
getgraphattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttributeGraph} = getgraphattr(NestedGraphs.getgraph(ag), k)
getvertexattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttributeGraph} = getvertexattr(NestedGraphs.getgraph(ag), k)
getedgeattr(ag::NestedGraph{T,G}, args...) where {T<:Integer,G<:AbstractAttributeGraph} = getedgeattr(NestedGraphs.getgraph(ag), args...)

hasgraphattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttibuteGraph} = hasgraphattr(NestedGraphs.getgraph(ag), k)
hasvertexattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttibuteGraph} = hasvertexattr(NestedGraphs.getgraph(ag), k)
hasedgeattr(ag::NestedGraph{T,G}, args...) where {T<:Integer,G<:AbstractAttibuteGraph} = hasedgeattr(NestedGraphs.getgraph(ag), args...)
hasgraphattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttributeGraph} = hasgraphattr(NestedGraphs.getgraph(ag), k)
hasvertexattr(ag::NestedGraph{T,G}, k) where {T<:Integer,G<:AbstractAttributeGraph} = hasvertexattr(NestedGraphs.getgraph(ag), k)
hasedgeattr(ag::NestedGraph{T,G}, args...) where {T<:Integer,G<:AbstractAttributeGraph} = hasedgeattr(NestedGraphs.getgraph(ag), args...)


function addvertex!(ng::NestedGraph{T,G}; subgraphs=1) where {T<:Integer, G<:AbstractAttibuteGraph}
function addvertex!(ng::NestedGraph{T,G}; subgraphs=1) where {T<:Integer, G<:AbstractAttributeGraph}
subgraph = first(subgraphs)
length(ng.grv) == 0 && (add_vertex!(ng, G()))
targetnode = nv(ng.grv[subgraph])+1
Expand All @@ -24,7 +24,7 @@ function addvertex!(ng::NestedGraph{T,G}; subgraphs=1) where {T<:Integer, G<:Abs
NestedGraphs._propagate_to_nested(ng, addvertex!, subgraphs)
end

function remvertex!(ng::NestedGraph{T,G}, v::T) where {T<:Integer, G<:AbstractAttibuteGraph}
function remvertex!(ng::NestedGraph{T,G}, v::T) where {T<:Integer, G<:AbstractAttributeGraph}
Graphs.has_vertex(ng, v) || return false
remvertex!(ng.flatgr, v)
nver = ng.vmap[v]
Expand All @@ -33,9 +33,9 @@ function remvertex!(ng::NestedGraph{T,G}, v::T) where {T<:Integer, G<:AbstractAt
NestedGraphs.update_vmapneds_after_delete!(ng, nver)
end

addedge!(mg::NestedGraph{T,G}, args...) where {T<:Integer, G<:AbstractAttibuteGraph} = add_edge!(mg, args...)
addedge!(mg::NestedGraph{T,G}, args...) where {T<:Integer, G<:AbstractAttributeGraph} = add_edge!(mg, args...)

function remedge!(ng::NestedGraph{T,G}, src::T, dst::T) where {T<:Integer, G<:AbstractAttibuteGraph}
function remedge!(ng::NestedGraph{T,G}, src::T, dst::T) where {T<:Integer, G<:AbstractAttributeGraph}
Graphs.has_edge(ng, src, dst) || return false
remedge!(ng.flatgr, src, dst)
srctup = ng.vmap[src]
Expand All @@ -47,37 +47,37 @@ function remedge!(ng::NestedGraph{T,G}, src::T, dst::T) where {T<:Integer, G<:Ab
end
end

addgraphattr!(ng::NestedGraph{T,G}, k, v) where {T<:Integer, G<:AbstractAttibuteGraph} = addgraphattr!(NestedGraphs.getgraph(ng), k, v)
remgraphattr!(ng::NestedGraph{T,G}, k) where {T<:Integer, G<:AbstractAttibuteGraph} = remgraphattr!(NestedGraphs.getgraph(ng), k)
addgraphattr!(ng::NestedGraph{T,G}, k, v) where {T<:Integer, G<:AbstractAttributeGraph} = addgraphattr!(NestedGraphs.getgraph(ng), k, v)
remgraphattr!(ng::NestedGraph{T,G}, k) where {T<:Integer, G<:AbstractAttributeGraph} = remgraphattr!(NestedGraphs.getgraph(ng), k)

function addvertexattr!(ng::NestedGraph{T,G}, k, v) where {T<:Integer, G<:AbstractAttibuteGraph}
function addvertexattr!(ng::NestedGraph{T,G}, k, v) where {T<:Integer, G<:AbstractAttributeGraph}
addvertexattr!(NestedGraphs.getgraph(ng), k, v)
addvertexattr!(ng.grv[ng.vmap[k][1]], ng.vmap[k][2], v)
end
function remvertexattr!(ng::NestedGraph{T,G}, k) where {T<:Integer, G<:AbstractAttibuteGraph}
function remvertexattr!(ng::NestedGraph{T,G}, k) where {T<:Integer, G<:AbstractAttributeGraph}
remvertexattr!(NestedGraphs.getgraph(ng), k)
remvertexattr!(ng.grv[ng.vmap[k][1]], ng.vmap[k][2])
end

remedgeattr!(ng::NestedGraph{T,G}, e::AbstractEdge, args...) where {T<:Integer, G<:AbstractAttibuteGraph} = remedgeattr!(ng, src(e), dst(e), args...)
function remedgeattr!(ng::NestedGraph{T,G}, s::T, d::T, args...) where {T<:Integer, G<:AbstractAttibuteGraph}
remedgeattr!(ng::NestedGraph{T,G}, e::AbstractEdge, args...) where {T<:Integer, G<:AbstractAttributeGraph} = remedgeattr!(ng, src(e), dst(e), args...)
function remedgeattr!(ng::NestedGraph{T,G}, s::T, d::T, args...) where {T<:Integer, G<:AbstractAttributeGraph}
remedgeattr!(NestedGraphs.getgraph(ng), s, d, args...)
if NestedGraphs.issamesubgraph(ng, s, d)
remedgeattr!(ng.grv[ng.vmap[s][1]], ng.vmap[s][2], ng.vmap[d][2], args...)
end
end

addedgeattr!(ng::NestedGraph{T,G}, e::AbstractEdge, args...) where {T<:Integer, G<:AbstractAttibuteGraph} = addedgeattr!(ng, src(e), dst(e), args...)
function addedgeattr!(ng::NestedGraph{T,G}, s::T, d::T, args...) where {T<:Integer, G<:AbstractAttibuteGraph}
addedgeattr!(ng::NestedGraph{T,G}, e::AbstractEdge, args...) where {T<:Integer, G<:AbstractAttributeGraph} = addedgeattr!(ng, src(e), dst(e), args...)
function addedgeattr!(ng::NestedGraph{T,G}, s::T, d::T, args...) where {T<:Integer, G<:AbstractAttributeGraph}
addedgeattr!(NestedGraphs.getgraph(ng), s, d, args...)
if NestedGraphs.issamesubgraph(ng, s, d)
addedgeattr!(ng.grv[ng.vmap[s][1]], ng.vmap[s][2], ng.vmap[d][2], args...)
end
end

vertex_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttibuteGraph} = vertex_attr(NestedGraphs.getgraph(mg))
edge_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttibuteGraph} = edge_attr(NestedGraphs.getgraph(mg))
graph_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttibuteGraph} = graph_attr(NestedGraphs.getgraph(mg))
vertex_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttributeGraph} = vertex_attr(NestedGraphs.getgraph(mg))
edge_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttributeGraph} = edge_attr(NestedGraphs.getgraph(mg))
graph_attr(mg::NestedGraph{T,G}) where {T<:Integer, G<:AbstractAttributeGraph} = graph_attr(NestedGraphs.getgraph(mg))

# I need to implement shallow copy
function NestedGraphs.shallowcopy_vertices!(g1::AttributeGraph{T,G,V}, g2::AttributeGraph{T,G,V}) where {T<:Integer,G<:AbstractGraph{T},V<:AbstractVector}
Expand All @@ -102,7 +102,7 @@ end


# multilayer.jl
function getsquashedgraph(ng::NestedGraph{T,R,N}, sqvertices::Vector{Vector{Q}}) where {T,R<:AbstractAttibuteGraph,N,Q<:Integer}
function getsquashedgraph(ng::NestedGraph{T,R,N}, sqvertices::Vector{Vector{Q}}) where {T,R<:AbstractAttributeGraph,N,Q<:Integer}
# squashedgraph = ng.flatgr |> deepcopy |> adjacency_matrix |> SimpleGraph
squashedgraph = getsimplegraphcopy(ng)
_rec_merge_vertices!(SimpleGraph(squashedgraph), sqvertices)
Expand Down
94 changes: 0 additions & 94 deletions src/attributegraphs.jl

This file was deleted.

16 changes: 8 additions & 8 deletions test/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.9.0"
julia_version = "1.9.1"
manifest_format = "2.0"
project_hash = "4c10ced6dbf6a1004a10f82866da531e325c4d73"

Expand All @@ -24,18 +24,18 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.AttributeGraphs]]
deps = ["DocStringExtensions", "Graphs"]
git-tree-sha1 = "35f8c0b552ad5ec872078db8c5cf61119b01671a"
git-tree-sha1 = "a92f0a56ce4faebcc8668d764a346be90bc5161f"
uuid = "d091dd56-f8c5-469d-b7f7-ff847498145f"
version = "0.2.0"
version = "0.3.0"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.Compat]]
deps = ["UUIDs"]
git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957"
git-tree-sha1 = "4e88377ae7ebeaf29a047aa1ee40826e0b708a5d"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.6.1"
version = "4.7.0"
weakdeps = ["Dates", "LinearAlgebra"]

[deps.Compat.extensions]
Expand All @@ -48,9 +48,9 @@ version = "1.0.2+0"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0"
git-tree-sha1 = "cf25ccb972fec4e4817764d01c82386ae94f77b4"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.13"
version = "0.18.14"

[[deps.Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -302,7 +302,7 @@ version = "1.2.13+0"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.7.0+0"
version = "5.8.0+0"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down

2 comments on commit ed46a04

@filchristou
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/86479

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" ed46a046718545e5ef8bf1ee4174de96aecb7ec4
git push origin v0.2.1

Please sign in to comment.