@@ -3,18 +3,18 @@ module NestedGraphsAttributeGraphsExt
33using NestedGraphs, Graphs, DocStringExtensions
44using AttributeGraphs
55
6- 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
6+ 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
77
8- getgraphattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttibuteGraph } = getgraphattr (NestedGraphs. getgraph (ag), k)
9- getvertexattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttibuteGraph } = getvertexattr (NestedGraphs. getgraph (ag), k)
10- getedgeattr (ag:: NestedGraph{T,G} , args... ) where {T<: Integer ,G<: AbstractAttibuteGraph } = getedgeattr (NestedGraphs. getgraph (ag), args... )
8+ getgraphattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttributeGraph } = getgraphattr (NestedGraphs. getgraph (ag), k)
9+ getvertexattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttributeGraph } = getvertexattr (NestedGraphs. getgraph (ag), k)
10+ getedgeattr (ag:: NestedGraph{T,G} , args... ) where {T<: Integer ,G<: AbstractAttributeGraph } = getedgeattr (NestedGraphs. getgraph (ag), args... )
1111
12- hasgraphattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttibuteGraph } = hasgraphattr (NestedGraphs. getgraph (ag), k)
13- hasvertexattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttibuteGraph } = hasvertexattr (NestedGraphs. getgraph (ag), k)
14- hasedgeattr (ag:: NestedGraph{T,G} , args... ) where {T<: Integer ,G<: AbstractAttibuteGraph } = hasedgeattr (NestedGraphs. getgraph (ag), args... )
12+ hasgraphattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttributeGraph } = hasgraphattr (NestedGraphs. getgraph (ag), k)
13+ hasvertexattr (ag:: NestedGraph{T,G} , k) where {T<: Integer ,G<: AbstractAttributeGraph } = hasvertexattr (NestedGraphs. getgraph (ag), k)
14+ hasedgeattr (ag:: NestedGraph{T,G} , args... ) where {T<: Integer ,G<: AbstractAttributeGraph } = hasedgeattr (NestedGraphs. getgraph (ag), args... )
1515
1616
17- function addvertex! (ng:: NestedGraph{T,G} ; subgraphs= 1 ) where {T<: Integer , G<: AbstractAttibuteGraph }
17+ function addvertex! (ng:: NestedGraph{T,G} ; subgraphs= 1 ) where {T<: Integer , G<: AbstractAttributeGraph }
1818 subgraph = first (subgraphs)
1919 length (ng. grv) == 0 && (add_vertex! (ng, G ()))
2020 targetnode = nv (ng. grv[subgraph])+ 1
@@ -24,7 +24,7 @@ function addvertex!(ng::NestedGraph{T,G}; subgraphs=1) where {T<:Integer, G<:Abs
2424 NestedGraphs. _propagate_to_nested (ng, addvertex!, subgraphs)
2525end
2626
27- function remvertex! (ng:: NestedGraph{T,G} , v:: T ) where {T<: Integer , G<: AbstractAttibuteGraph }
27+ function remvertex! (ng:: NestedGraph{T,G} , v:: T ) where {T<: Integer , G<: AbstractAttributeGraph }
2828 Graphs. has_vertex (ng, v) || return false
2929 remvertex! (ng. flatgr, v)
3030 nver = ng. vmap[v]
@@ -33,9 +33,9 @@ function remvertex!(ng::NestedGraph{T,G}, v::T) where {T<:Integer, G<:AbstractAt
3333 NestedGraphs. update_vmapneds_after_delete! (ng, nver)
3434end
3535
36- addedge! (mg:: NestedGraph{T,G} , args... ) where {T<: Integer , G<: AbstractAttibuteGraph } = add_edge! (mg, args... )
36+ addedge! (mg:: NestedGraph{T,G} , args... ) where {T<: Integer , G<: AbstractAttributeGraph } = add_edge! (mg, args... )
3737
38- function remedge! (ng:: NestedGraph{T,G} , src:: T , dst:: T ) where {T<: Integer , G<: AbstractAttibuteGraph }
38+ function remedge! (ng:: NestedGraph{T,G} , src:: T , dst:: T ) where {T<: Integer , G<: AbstractAttributeGraph }
3939 Graphs. has_edge (ng, src, dst) || return false
4040 remedge! (ng. flatgr, src, dst)
4141 srctup = ng. vmap[src]
@@ -47,37 +47,37 @@ function remedge!(ng::NestedGraph{T,G}, src::T, dst::T) where {T<:Integer, G<:Ab
4747 end
4848end
4949
50- addgraphattr! (ng:: NestedGraph{T,G} , k, v) where {T<: Integer , G<: AbstractAttibuteGraph } = addgraphattr! (NestedGraphs. getgraph (ng), k, v)
51- remgraphattr! (ng:: NestedGraph{T,G} , k) where {T<: Integer , G<: AbstractAttibuteGraph } = remgraphattr! (NestedGraphs. getgraph (ng), k)
50+ addgraphattr! (ng:: NestedGraph{T,G} , k, v) where {T<: Integer , G<: AbstractAttributeGraph } = addgraphattr! (NestedGraphs. getgraph (ng), k, v)
51+ remgraphattr! (ng:: NestedGraph{T,G} , k) where {T<: Integer , G<: AbstractAttributeGraph } = remgraphattr! (NestedGraphs. getgraph (ng), k)
5252
53- function addvertexattr! (ng:: NestedGraph{T,G} , k, v) where {T<: Integer , G<: AbstractAttibuteGraph }
53+ function addvertexattr! (ng:: NestedGraph{T,G} , k, v) where {T<: Integer , G<: AbstractAttributeGraph }
5454 addvertexattr! (NestedGraphs. getgraph (ng), k, v)
5555 addvertexattr! (ng. grv[ng. vmap[k][1 ]], ng. vmap[k][2 ], v)
5656end
57- function remvertexattr! (ng:: NestedGraph{T,G} , k) where {T<: Integer , G<: AbstractAttibuteGraph }
57+ function remvertexattr! (ng:: NestedGraph{T,G} , k) where {T<: Integer , G<: AbstractAttributeGraph }
5858 remvertexattr! (NestedGraphs. getgraph (ng), k)
5959 remvertexattr! (ng. grv[ng. vmap[k][1 ]], ng. vmap[k][2 ])
6060end
6161
62- remedgeattr! (ng:: NestedGraph{T,G} , e:: AbstractEdge , args... ) where {T<: Integer , G<: AbstractAttibuteGraph } = remedgeattr! (ng, src (e), dst (e), args... )
63- function remedgeattr! (ng:: NestedGraph{T,G} , s:: T , d:: T , args... ) where {T<: Integer , G<: AbstractAttibuteGraph }
62+ remedgeattr! (ng:: NestedGraph{T,G} , e:: AbstractEdge , args... ) where {T<: Integer , G<: AbstractAttributeGraph } = remedgeattr! (ng, src (e), dst (e), args... )
63+ function remedgeattr! (ng:: NestedGraph{T,G} , s:: T , d:: T , args... ) where {T<: Integer , G<: AbstractAttributeGraph }
6464 remedgeattr! (NestedGraphs. getgraph (ng), s, d, args... )
6565 if NestedGraphs. issamesubgraph (ng, s, d)
6666 remedgeattr! (ng. grv[ng. vmap[s][1 ]], ng. vmap[s][2 ], ng. vmap[d][2 ], args... )
6767 end
6868end
6969
70- addedgeattr! (ng:: NestedGraph{T,G} , e:: AbstractEdge , args... ) where {T<: Integer , G<: AbstractAttibuteGraph } = addedgeattr! (ng, src (e), dst (e), args... )
71- function addedgeattr! (ng:: NestedGraph{T,G} , s:: T , d:: T , args... ) where {T<: Integer , G<: AbstractAttibuteGraph }
70+ addedgeattr! (ng:: NestedGraph{T,G} , e:: AbstractEdge , args... ) where {T<: Integer , G<: AbstractAttributeGraph } = addedgeattr! (ng, src (e), dst (e), args... )
71+ function addedgeattr! (ng:: NestedGraph{T,G} , s:: T , d:: T , args... ) where {T<: Integer , G<: AbstractAttributeGraph }
7272 addedgeattr! (NestedGraphs. getgraph (ng), s, d, args... )
7373 if NestedGraphs. issamesubgraph (ng, s, d)
7474 addedgeattr! (ng. grv[ng. vmap[s][1 ]], ng. vmap[s][2 ], ng. vmap[d][2 ], args... )
7575 end
7676end
7777
78- vertex_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttibuteGraph } = vertex_attr (NestedGraphs. getgraph (mg))
79- edge_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttibuteGraph } = edge_attr (NestedGraphs. getgraph (mg))
80- graph_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttibuteGraph } = graph_attr (NestedGraphs. getgraph (mg))
78+ vertex_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttributeGraph } = vertex_attr (NestedGraphs. getgraph (mg))
79+ edge_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttributeGraph } = edge_attr (NestedGraphs. getgraph (mg))
80+ graph_attr (mg:: NestedGraph{T,G} ) where {T<: Integer , G<: AbstractAttributeGraph } = graph_attr (NestedGraphs. getgraph (mg))
8181
8282# I need to implement shallow copy
8383function NestedGraphs. shallowcopy_vertices! (g1:: AttributeGraph{T,G,V} , g2:: AttributeGraph{T,G,V} ) where {T<: Integer ,G<: AbstractGraph{T} ,V<: AbstractVector }
102102
103103
104104# multilayer.jl
105- function getsquashedgraph (ng:: NestedGraph{T,R,N} , sqvertices:: Vector{Vector{Q}} ) where {T,R<: AbstractAttibuteGraph ,N,Q<: Integer }
105+ function getsquashedgraph (ng:: NestedGraph{T,R,N} , sqvertices:: Vector{Vector{Q}} ) where {T,R<: AbstractAttributeGraph ,N,Q<: Integer }
106106# squashedgraph = ng.flatgr |> deepcopy |> adjacency_matrix |> SimpleGraph
107107 squashedgraph = getsimplegraphcopy (ng)
108108 _rec_merge_vertices! (SimpleGraph (squashedgraph), sqvertices)
0 commit comments