Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
7 changes: 4 additions & 3 deletions src/abstractnamedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ parent_graph(graph::AbstractNamedGraph) = not_implemented()
# ?
parent_graph_type(graph::AbstractNamedGraph) = not_implemented()

function Graphs.has_vertex(graph::AbstractNamedGraph, vertex)
return not_implemented()
end

parent_vertextype(graph::AbstractNamedGraph) = vertextype(parent_graph(graph))

# Convert vertex to parent vertex
Expand Down Expand Up @@ -137,9 +141,6 @@ function parent_edges_to_edges(graph::AbstractNamedGraph, parent_edges)
return map(parent_edge_to_edge(graph), parent_edges)
end

# TODO: This is `O(nv(g))`, use `haskey(vertex_to_parent_vertex(g), v)` instead?
has_vertex(g::AbstractNamedGraph, v) = v in vertices(g)

function edges(graph::AbstractNamedGraph)
return parent_edges_to_edges(graph, parent_edges(graph))
end
Expand Down
3 changes: 3 additions & 0 deletions src/namedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ vertices(graph::GenericNamedGraph) = getfield(graph, :vertices)
function vertex_to_parent_vertex(graph::GenericNamedGraph, vertex)
return graph.vertex_to_parent_vertex[vertex]
end
function Graphs.has_vertex(graph::GenericNamedGraph, vertex)
return haskey(graph.vertex_to_parent_vertex, vertex)
end

function convert_vertextype(V::Type, graph::GenericNamedGraph)
return GenericNamedGraph(parent_graph(graph), convert(Vector{V}, vertices(graph)))
Expand Down