Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Apr 17, 2024
1 parent c7ef979 commit a4163c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/abstractdatagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Dictionaries: set!, unset!
using Graphs:
Graphs, AbstractEdge, AbstractGraph, IsDirected, add_edge!, edges, ne, nv, vertices
using NamedGraphs.GraphsExtensions: GraphsExtensions, incident_edges, vertextype
using SimpleTraits: SimpleTraits, @traitfn
using SimpleTraits: SimpleTraits, Not, @traitfn

abstract type AbstractDataGraph{V,VD,ED} <: AbstractGraph{V} end

Expand Down Expand Up @@ -273,7 +273,7 @@ end

function map_vertex_data(f, graph::AbstractDataGraph; vertices=nothing)
graph′ = copy(graph)
vs = isnothing(vertices) ? vertices(graph) : vertices
vs = isnothing(vertices) ? Graphs.vertices(graph) : vertices
for v in vs
graph′[v] = f(graph[v])
end
Expand All @@ -282,7 +282,7 @@ end

function map_edge_data(f, graph::AbstractDataGraph; edges=nothing)
graph′ = copy(graph)
es = isnothing(edges) ? edges(graph) : edges
es = isnothing(edges) ? Graphs.edges(graph) : edges
for e in es
if isassigned(graph, e)
graph′[e] = f(graph[e])
Expand Down
2 changes: 1 addition & 1 deletion src/arrange.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Graphs: IsDirected, src, dst
using SimpleTraits: SimpleTraits, @traitfn
using SimpleTraits: SimpleTraits, Not, @traitfn

# TODO: Use a function `arrange` like in MetaGraphsNext:
# https://github.com/JuliaGraphs/MetaGraphsNext.jl/blob/1539095ee6088aba0d5b1cb057c339ad92557889/src/metagraph.jl#L75-L80
Expand Down
4 changes: 3 additions & 1 deletion src/datagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ DataGraph{V,VD,ED,G}(graph::DataGraph{V,VD,ED,G}) where {V,VD,ED,G} = copy(graph
DataGraph{V,VD,ED}(graph::DataGraph{V,VD,ED}) where {V,VD,ED} = copy(graph)
DataGraph{V,VD}(graph::DataGraph{V,VD}) where {V,VD} = copy(graph)
DataGraph{V}(graph::DataGraph{V}) where {V} = copy(graph)

# TODO: Test this function!
function DataGraph{V}(graph::DataGraph) where {V}
# TODO: Make sure this properly copies
converted_underlying_graph = convert_vertextype(V, underlying_graph(graph))
converted_vertex_data = Dictionary{V}(vertex_data(graph))
converted_edge_data = Dictionary{edgetype(converted_underlying_graph)}(edge_data(graph))
return DataGraph{V}(
return _DataGraph(
converted_underlying_graph, converted_vertex_data, converted_edge_data
)
end
Expand Down
2 changes: 1 addition & 1 deletion src/traits/isunderlyinggraph.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SimpleTraits: SimpleTraits, @traitdef, @traitimpl
using SimpleTraits: SimpleTraits, Not, @traitdef, @traitimpl

@traitdef IsUnderlyingGraph{X}
#! format: off
Expand Down

0 comments on commit a4163c2

Please sign in to comment.