Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Apr 24, 2024
1 parent 843690b commit be06026
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion src/namedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit be06026

Please sign in to comment.