diff --git a/src/metagraphml.jl b/src/metagraphml.jl index 1599705..2b3ae7f 100644 --- a/src/metagraphml.jl +++ b/src/metagraphml.jl @@ -33,20 +33,23 @@ edgedefaults(keyprops::Dict{String, AttrKey}) = Iterators.filter(v -> getfield(v function addmetagraphmlnode!(gr::AbstractGraph, node::EzXML.Node, defaults::Vector{AttrKey}, keyprops::Dict{String, AttrKey}, ns::String) add_vertex!(gr) i = length(vertices(gr)) - set_prop!(gr, i, :id, node["id"]) + set_prop!(gr, i, :id, string(node["id"])) for def in defaults set_prop!(gr, i, Symbol(def.name), def.default) end for data in findall("x:data", node, ["x"=>ns]) - set_prop!(gr, i, Symbol(keyprops[data["key"]].name), keyprops[data["key"]].type == String ? strip(nodecontent(data)) : parse(keyprops[data["key"]].type, nodecontent(data))) + key = keyprops[data["key"]] + set_prop!(gr, i, Symbol(key.name), key.type == String || key.name == "id" ? strip(nodecontent(data)) : parse(key.type, nodecontent(data))) end end function addmetagraphmledge!(gr::AbstractGraph, edge::EzXML.Node, defaults::Vector{AttrKey}, keyprops::Dict{String, AttrKey}, ns::String) - srcnode = gr[edge["source"],:id] - trgnode = gr[edge["target"],:id] + srcnode = gr[string(edge["source"]),:id] + trgnode = gr[string(edge["target"]),:id] add_edge!(gr, srcnode, trgnode) - set_prop!(gr, srcnode, trgnode, :id, edge["id"]) + if haskey(edge, "id") + set_prop!(gr, srcnode, trgnode, :id, string(edge["id"])) + end for def in defaults set_prop!(gr, srcnode, trgnode, Symbol(def.name), def.default) end @@ -79,7 +82,15 @@ end function _loadmetagraph_fromnode(graphnode::EzXML.Node, keyprops::Dict{String, AttrKey}) ns = namespace(graphnode) gr = instantiatemetagraph(graphnode) - set_prop!(gr, :id, graphnode["id"]) + if haskey(graphnode, "id") + set_prop!(gr, :id, string(graphnode["id"])) + end + + for data in findall("x:data", graphnode, ["x"=>ns]) + key = keyprops[data["key"]] + set_prop!(gr, Symbol(key.name), key.type == String || key.name == "id" ? strip(nodecontent(data)) : parse(key.type, nodecontent(data))) + end + set_indexing_prop!(gr, :id) for (i,node) in enumerate(findall("x:node", graphnode, ["x"=>ns])) addmetagraphmlnode!(gr, node, nodedefaults(keyprops), keyprops, ns) @@ -110,9 +121,12 @@ function loadmetagraphml_mult(io::IO) graphnodes = findall("//x:graph", doc.root, ["x"=>ns]) + gcount = 1 + graphs = Dict{String, AbstractMetaGraph}() for graphnode in graphnodes - graphs[graphnode["id"]] = _loadmetagraph_fromnode(graphnode, keyprops) + gkey = haskey(graphnode, "id") ? string(graphnode["id"]) : string("graph", gcount) + graphs[gkey] = _loadmetagraph_fromnode(graphnode, keyprops) end return graphs end diff --git a/test/Manifest.toml b/test/Manifest.toml index 2d44cf4..4a41976 100644 --- a/test/Manifest.toml +++ b/test/Manifest.toml @@ -1,13 +1,13 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.4" +julia_version = "1.9.1" manifest_format = "2.0" project_hash = "fd4b68bfd9948c52096ec5fe8b1aea5986f0fb1d" [[deps.AbstractTrees]] -git-tree-sha1 = "52b3b436f8f73133d7bc3a6c71ee7ed6ab2ab754" +git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" -version = "0.4.3" +version = "0.4.4" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" @@ -26,21 +26,25 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.Compat]] -deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "00a2cccc7f098ff3b66806862d275ca3db9e6e5a" +deps = ["UUIDs"] +git-tree-sha1 = "4e88377ae7ebeaf29a047aa1ee40826e0b708a5d" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.5.0" +version = "4.7.0" +weakdeps = ["Dates", "LinearAlgebra"] + + [deps.Compat.extensions] + CompatLinearAlgebraExt = "LinearAlgebra" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.1+0" +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"] @@ -53,7 +57,9 @@ version = "1.2.0" [[deps.DelimitedFiles]] deps = ["Mmap"] +git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae" uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" +version = "1.9.1" [[deps.Distributed]] deps = ["Random", "Serialization", "Sockets"] @@ -78,26 +84,36 @@ version = "1.1.0" [[deps.FileIO]] deps = ["Pkg", "Requires", "UUIDs"] -git-tree-sha1 = "7be5f99f7d15578798f338f5433b6c432ea8037b" +git-tree-sha1 = "299dc33549f68299137e51e6d49a13b5b1da9673" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.16.0" +version = "1.16.1" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[deps.GraphIO]] deps = ["DelimitedFiles", "Graphs", "Requires", "SimpleTraits"] -git-tree-sha1 = "65431b08a6943198d8ee4b8f74fd1031d2d4a5df" -repo-rev = "typedefreqmov" -repo-url = "https://github.com/filchristou/GraphIO.jl" +git-tree-sha1 = "bc5b7609e9f4583f303a0ab2a7016ea318464da0" uuid = "aa1b3936-2fda-51b9-ab35-c553d3a640a2" -version = "0.6.0" +version = "0.7.0" + + [deps.GraphIO.extensions] + GraphIODOTExt = "ParserCombinator" + GraphIOGEXFExt = "EzXML" + GraphIOGMLExt = "ParserCombinator" + GraphIOGraphMLExt = "EzXML" + GraphIOLGCompressedExt = "CodecZlib" + + [deps.GraphIO.weakdeps] + CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" + EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" + ParserCombinator = "fae87a5f-d1ad-5cf0-8f61-c941e1580b46" [[deps.Graphs]] deps = ["ArnoldiMethod", "Compat", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "ba2d094a88b6b287bd25cfa86f301e7693ffae2f" +git-tree-sha1 = "1cf1d7dcb4bc32d7b4a5add4232db3750c27ecb4" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" -version = "1.7.4" +version = "1.8.0" [[deps.Inflate]] git-tree-sha1 = "5cd07aab533df5170988219191dfad0519391428" @@ -109,10 +125,10 @@ deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[deps.JLD2]] -deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"] -git-tree-sha1 = "ec8a9c9f0ecb1c687e34c1fda2699de4d054672a" +deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "Printf", "Reexport", "Requires", "TranscodingStreams", "UUIDs"] +git-tree-sha1 = "42c17b18ced77ff0be65957a591d34f4ed57c631" uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" -version = "0.4.29" +version = "0.4.31" [[deps.JLLWrappers]] deps = ["Preferences"] @@ -149,7 +165,7 @@ uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" version = "1.16.1+2" [[deps.LinearAlgebra]] -deps = ["Libdl", "libblastrampoline_jll"] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[deps.Logging]] @@ -168,7 +184,7 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.0+0" +version = "2.28.2+0" [[deps.MetaGraphs]] deps = ["Graphs", "JLD2", "Random"] @@ -181,13 +197,21 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2022.2.1" +version = "2022.10.11" [[deps.NestedGraphs]] -deps = ["AbstractTrees", "DocStringExtensions", "Graphs", "MetaGraphs"] -git-tree-sha1 = "05039157c52ff19d517e2c21d1f9af033b453963" +deps = ["AbstractTrees", "DocStringExtensions", "Graphs", "SimpleTraits"] +git-tree-sha1 = "516b6c63e1cbebbf40d4d4bdc7f01a78491ab3fc" uuid = "03c36417-ddab-428a-818d-5359aee292ef" -version = "0.1.0" +version = "0.2.2" + + [deps.NestedGraphs.extensions] + NestedGraphsAttributeGraphsExt = "AttributeGraphs" + NestedGraphsMetaGraphsExt = "MetaGraphs" + + [deps.NestedGraphs.weakdeps] + AttributeGraphs = "d091dd56-f8c5-469d-b7f7-ff847498145f" + MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" [[deps.NestedGraphsIO]] deps = ["DocStringExtensions", "EzXML", "GraphIO", "Graphs", "MetaGraphs", "NestedGraphs"] @@ -202,23 +226,23 @@ version = "1.2.0" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.20+0" +version = "0.3.21+4" [[deps.OrderedCollections]] -git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" +git-tree-sha1 = "d321bf2de576bf25ec4d3e4360faca399afca282" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.4.1" +version = "1.6.0" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.8.0" +version = "1.9.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" +git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.3.0" +version = "1.4.0" [[deps.Printf]] deps = ["Unicode"] @@ -264,14 +288,18 @@ version = "0.9.4" uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[deps.SparseArrays]] -deps = ["LinearAlgebra", "Random"] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.StaticArrays]] -deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] -git-tree-sha1 = "6954a456979f23d05085727adb17c4551c19ecd1" +deps = ["LinearAlgebra", "Random", "StaticArraysCore"] +git-tree-sha1 = "0da7e6b70d1bb40b1ace3b576da9ea2992f76318" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.5.12" +version = "1.6.0" +weakdeps = ["Statistics"] + + [deps.StaticArrays.extensions] + StaticArraysStatisticsExt = "Statistics" [[deps.StaticArraysCore]] git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" @@ -281,16 +309,22 @@ version = "1.4.0" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.9.0" + +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "5.10.1+6" [[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" -version = "1.0.0" +version = "1.0.3" [[deps.Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -version = "1.10.1" +version = "1.10.0" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] @@ -304,9 +338,9 @@ version = "2.0.0" [[deps.TranscodingStreams]] deps = ["Random", "Test"] -git-tree-sha1 = "94f38103c984f89cf77c402f2a68dbd870f8165f" +git-tree-sha1 = "9a6ae7ed916312b41236fcef7e0af564ef934769" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.9.11" +version = "0.9.13" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -324,12 +358,12 @@ version = "2.10.3+0" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.12+3" +version = "1.2.13+0" [[deps.libblastrampoline_jll]] -deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] +deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.1.1+0" +version = "5.8.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"]