Skip to content
Open
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DataGraphs"
uuid = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a"
version = "0.4.2"
version = "0.4.3"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org> and contributors"]

[workspace]
Expand Down
3 changes: 3 additions & 0 deletions src/DataGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ include("dataview.jl")
include("abstractdatagraph.jl")
include("indexing.jl")
include("datagraph.jl")
include("abstractedgeorvertexdatagraph.jl")
include("vertexdatagraph.jl")
include("edgedatagraph.jl")
# TODO: Turn into an extension once `PartitionedGraphs` is excised.
include("lib/DataGraphsPartitionedGraphsExt/src/DataGraphsPartitionedGraphsExt.jl")

Expand Down
30 changes: 24 additions & 6 deletions src/abstractdatagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ using NamedGraphs.GraphsExtensions: GraphsExtensions, add_edges!, add_vertices!,
using NamedGraphs.OrdinalIndexing: OrdinalSuffixedInteger
using NamedGraphs.SimilarType: similar_type
using NamedGraphs: NamedGraphs, AbstractEdges, AbstractNamedEdge, AbstractNamedGraph,
AbstractVertices, NamedDiGraph, NamedGraph, position_graph_type, similar_graph
AbstractVertices, NamedDiGraph, NamedGraph, Vertices, position_graph_type,
similar_graph, subgraph_edges
using SimpleTraits: SimpleTraits, @traitfn, Not

abstract type AbstractDataGraph{V, VD, ED} <: AbstractNamedGraph{V} end
Expand All @@ -21,12 +22,15 @@ edge_data_type(::Type{<:AbstractDataGraph{V, VD, ED}}) where {V, VD, ED} = ED
# TODO: Define for `AbstractGraph` as a `DataGraphInterface`.
underlying_graph(::AbstractDataGraph) = not_implemented()

# `isassigned`
is_vertex_assigned(::AbstractDataGraph, vertex) = not_implemented()
is_edge_assigned(::AbstractDataGraph, edge) = not_implemented()

# `getindex`
get_vertex_data(::AbstractDataGraph, vertex) = not_implemented()
get_edge_data(::AbstractDataGraph, edge) = not_implemented()

# `setindex!`
set_vertex_data!(::AbstractDataGraph, data, vertex) = not_implemented()
set_edge_data!(::AbstractDataGraph, data, edge) = not_implemented()

Expand Down Expand Up @@ -57,9 +61,7 @@ function assigned_edges(graph::AbstractGraph)
return Indices(filter(e -> isassigned(graph, e), edges(graph)))
end

function Graphs.edgetype(graph::AbstractDataGraph)
return Graphs.edgetype(underlying_graph(graph))
end
Graphs.edgetype(graph::AbstractDataGraph) = edgetype(underlying_graph(graph))
function Graphs.edgetype(graph_type::Type{<:AbstractDataGraph})
return edgetype(underlying_graph_type(graph_type))
end
Expand All @@ -75,11 +77,27 @@ function NamedGraphs.position_graph_type(type::Type{<:AbstractDataGraph})
return position_graph_type(underlying_graph_type(type))
end

function Base.copy(graph::AbstractDataGraph)
copy_graph = similar_graph(graph)
copyto!(copy_graph, graph)
return graph
end

function Base.copyto!(dst_graph::AbstractDataGraph, src_graph::AbstractDataGraph)
vertex_data(dst_graph) .= vertex_data(src_graph)
edge_data(dst_graph) .= edge_data(src_graph)
return dst_graph
end
function Base.copyto!(
graph_dst::AbstractDataGraph,
dict_src::Union{Dict, AbstractDictionary},
dimnames = keys(dict_src)
)
for key in dimnames
graph_dst[key] = dict_src[key]
end
return graph_dst
end

# Graphs overloads
function Graphs.vertices(graph::AbstractDataGraph)
Expand Down Expand Up @@ -110,8 +128,8 @@ GraphsExtensions.convert_vertextype(::Type, ::AbstractDataGraph) = not_implement

function Base.:(==)(dg1::AbstractDataGraph, dg2::AbstractDataGraph)
underlying_graph(dg1) == underlying_graph(dg2) || return false
vertex_data(dg1) == vertex_data(dg2) || return false
edge_data(dg1) == edge_data(dg2) || return false
assigned_vertex_data(dg1) == assigned_vertex_data(dg2) || return false
assigned_edge_data(dg1) == assigned_edge_data(dg2) || return false
return true
end

Expand Down
Loading
Loading