From be060262d54bea14947920d260bae82d2a812855 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 24 Apr 2024 16:21:27 -0400 Subject: [PATCH] Fix tests --- README.md | 24 ++++++++++++------------ src/namedgraph.jl | 5 ++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9cf5d58..3a8c865 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ julia> using NamedGraphs.GraphsExtensions: ⊔, disjoint_union, subgraph, rename julia> g = NamedGraph(grid((4,)), ["A", "B", "C", "D"]) NamedGraphs.NamedGraph{String} with 4 vertices: -4-element Vector{String}: +4-element Dictionaries.Indices{String} "A" "B" "C" @@ -82,7 +82,7 @@ julia> neighbors(g, "B") julia> subgraph(g, ["A", "B"]) NamedGraphs.NamedGraph{String} with 2 vertices: -2-element Vector{String}: +2-element Dictionaries.Indices{String} "A" "B" @@ -109,7 +109,7 @@ julia> dims = (2, 2) julia> g = NamedGraph(grid(dims), Tuple.(CartesianIndices(dims))) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Vector{Tuple{Int64, Int64}}: +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -153,7 +153,7 @@ You can use vertex names to get [induced subgraphs](https://juliagraphs.org/Grap ```julia julia> subgraph(v -> v[1] == 1, g) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Vector{Tuple{Int64, Int64}}: +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (1, 2) @@ -163,7 +163,7 @@ and 1 edge(s): julia> subgraph(v -> v[2] == 2, g) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Vector{Tuple{Int64, Int64}}: +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 2) (2, 2) @@ -173,7 +173,7 @@ and 1 edge(s): julia> subgraph(g, [(1, 1), (2, 2)]) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 2 vertices: -2-element Vector{Tuple{Int64, Int64}}: +2-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 2) @@ -187,7 +187,7 @@ You can also take [disjoint unions](https://en.wikipedia.org/wiki/Disjoint_union ```julia julia> g₁ = g NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Vector{Tuple{Int64, Int64}}: +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -202,7 +202,7 @@ and 4 edge(s): julia> g₂ = g NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Vector{Tuple{Int64, Int64}}: +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -217,7 +217,7 @@ and 4 edge(s): julia> disjoint_union(g₁, g₂) NamedGraphs.NamedGraph{Tuple{Tuple{Int64, Int64}, Int64}} with 8 vertices: -8-element Vector{Tuple{Tuple{Int64, Int64}, Int64}}: +8-element Dictionaries.Indices{Tuple{Tuple{Int64, Int64}, Int64}} ((1, 1), 1) ((2, 1), 1) ((1, 2), 1) @@ -240,7 +240,7 @@ and 8 edge(s): julia> g₁ ⊔ g₂ # Same as above NamedGraphs.NamedGraph{Tuple{Tuple{Int64, Int64}, Int64}} with 8 vertices: -8-element Vector{Tuple{Tuple{Int64, Int64}, Int64}}: +8-element Dictionaries.Indices{Tuple{Tuple{Int64, Int64}, Int64}} ((1, 1), 1) ((2, 1), 1) ((1, 2), 1) @@ -280,7 +280,7 @@ The original graphs can be obtained from subgraphs: ```julia julia> rename_vertices(first, subgraph(v -> v[2] == 1, g₁ ⊔ g₂)) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Vector{Tuple{Int64, Int64}}: +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) @@ -295,7 +295,7 @@ and 4 edge(s): julia> rename_vertices(first, subgraph(v -> v[2] == 2, g₁ ⊔ g₂)) NamedGraphs.NamedGraph{Tuple{Int64, Int64}} with 4 vertices: -4-element Vector{Tuple{Int64, Int64}}: +4-element Dictionaries.Indices{Tuple{Int64, Int64}} (1, 1) (2, 1) (1, 2) diff --git a/src/namedgraph.jl b/src/namedgraph.jl index 43fd173..c86a2b7 100644 --- a/src/namedgraph.jl +++ b/src/namedgraph.jl @@ -29,7 +29,10 @@ end function ordinal_vertex_to_vertex(graph::GenericNamedGraph, ordinal_vertex::Integer) return graph.ordered_vertices[ordinal_vertex] end -Graphs.vertices(graph::GenericNamedGraph) = graph.ordered_vertices + +# TODO: Decide what this should output. +# Graphs.vertices(graph::GenericNamedGraph) = graph.ordered_vertices +Graphs.vertices(graph::GenericNamedGraph) = keys(graph.vertex_to_ordinal_vertex) function Graphs.add_vertex!(graph::GenericNamedGraph, vertex) if vertex ∈ vertices(graph)