Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to NamedGraphs v0.4 #24

Merged
merged 11 commits into from
Apr 17, 2024
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
14 changes: 11 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
name = "DataGraphs"
uuid = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a"
authors = ["Matthew Fishman <[email protected]> and contributors"]
version = "0.1.13"
version = "0.2.0"

[deps]
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"

[weakdeps]
GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889"

[extensions]
DataGraphsGraphsFlowsExt = "GraphsFlows"

[compat]
Dictionaries = "0.4"
Graphs = "1"
GraphsFlows = "0.1.1"
NamedGraphs = "0.1.19"
NamedGraphs = "0.4"
PackageExtensionCompat = "1"
SimpleTraits = "0.9"
julia = "1.7"

[extras]
GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
Expand Down
4 changes: 4 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
DataGraphs = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
7 changes: 3 additions & 4 deletions examples/datagraph.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using DataGraphs
using Dictionaries
using Graphs
using DataGraphs: DataGraph
using Graphs: Edge, grid, has_edge, has_vertex

g = grid((4,))
dg = DataGraph(g, String, Symbol)
dg = DataGraph(g; vertex_data_eltype=String, edge_data_eltype=Symbol)
@show !isassigned(dg, Edge(1, 2))
@show !isassigned(dg, 1 => 2)
@show !isassigned(dg, Edge(1 => 2))
Expand Down
9 changes: 5 additions & 4 deletions examples/disjoint_union.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Graphs
using NamedGraphs
using DataGraphs
using Graphs: edges, has_edge, has_vertex, ne, nv, vertices
using NamedGraphs.GraphsExtensions: ⊔
using NamedGraphs.NamedGraphGenerators: named_grid
using DataGraphs: DataGraph

g = DataGraph(named_grid((2, 2)), String, String)
g = DataGraph(named_grid((2, 2)); vertex_data_eltype=String, edge_data_eltype=String)

for v in vertices(g)
g[v] = "V$v"
Expand Down
14 changes: 8 additions & 6 deletions examples/multidimdatagraph_1d.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using DataGraphs
using Graphs
using NamedGraphs
using DataGraphs: DataGraph
using Graphs: grid, has_edge, has_vertex
using NamedGraphs: NamedGraph, NamedEdge

g = NamedGraph(grid((4,)), ["A", "B", "C", "D"])
dg = DataGraph(g, String, Symbol)
dg = DataGraph(g; vertex_data_eltype=String, edge_data_eltype=Symbol)

@show has_vertex(dg, "A")
@show has_vertex(dg, "D")
@show !has_vertex(dg, 0)
@show !has_vertex(dg, 5)

# Broken, see https://github.com/andyferris/Dictionaries.jl/issues/143.
# @show !has_vertex(dg, 0)
# @show !has_vertex(dg, 5)

@show has_edge(dg, "A", "B")
@show has_edge(dg, "A" => "B")
Expand Down
9 changes: 4 additions & 5 deletions examples/multidimdatagraph_2d.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using DataGraphs
using NamedGraphs
using Dictionaries
using Graphs
using DataGraphs: DataGraph
using NamedGraphs: NamedEdge
using NamedGraphs.NamedGraphGenerators: named_grid

g = named_grid((2, 2))
dg = DataGraph(g, String, String)
dg = DataGraph(g; vertex_data_eltype=String, edge_data_eltype=String)

dg[1, 1] = "X11"

Expand Down
10 changes: 5 additions & 5 deletions examples/slicing.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using DataGraphs
using NamedGraphs
using Dictionaries
using Graphs
using DataGraphs: DataGraph
using NamedGraphs.GraphsExtensions: subgraph
using NamedGraphs.NamedGraphGenerators: named_grid
using Graphs: ne, nv

g = named_grid((2, 2))
dg = DataGraph(g, String, String)
dg = DataGraph(g; vertex_data_eltype=String, edge_data_eltype=String)

dg[1, 1] = "V11"
dg[1, 2] = "V12"
Expand Down
8 changes: 8 additions & 0 deletions ext/DataGraphsGraphsFlowsExt/DataGraphsGraphsFlowsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module DataGraphsGraphsFlowsExt
using DataGraphs: AbstractDataGraph, underlying_graph
using GraphsFlows: GraphsFlows

function GraphsFlows.mincut(graph::AbstractDataGraph, args...; kwargs...)
return GraphsFlows.mincut(underlying_graph(graph), args...; kwargs...)
end
end
14 changes: 14 additions & 0 deletions ext/DataGraphsNamedGraphsExt/DataGraphsNamedGraphsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module DataGraphsNamedGraphsExt
using DataGraphs: DataGraphs, AbstractDataGraph, underlying_graph
using NamedGraphs: NamedGraphs, AbstractNamedGraph

DataGraphs.is_underlying_graph(::Type{<:AbstractNamedGraph}) = true

for f in [:(NamedGraphs.parent_graph), :(NamedGraphs.parent_vertices_to_vertices)]
@eval begin
function $f(graph::AbstractDataGraph, args...; kwargs...)
return $f(underlying_graph(graph), args...; kwargs...)
end
end
end
end
137 changes: 11 additions & 126 deletions src/DataGraphs.jl
Original file line number Diff line number Diff line change
@@ -1,132 +1,17 @@
module DataGraphs
using Dictionaries
using Graphs
using Graphs.SimpleGraphs # AbstractSimpleGraph
using GraphsFlows
using NamedGraphs
using SimpleTraits

using NamedGraphs: AbstractNamedGraph, all_edges

#
# imports
#

import Base:
get,
getindex,
setindex!,
convert,
show,
isassigned,
eltype,
copy,
hvncat,
hcat,
vcat,
union,
zero

import Graphs:
a_star,
adjacency_matrix,
add_edge!,
add_vertex!,
bellman_ford_shortest_paths,
bfs_parents,
bfs_tree,
boruvka_mst,
center,
common_neighbors,
connected_components,
connected_components!,
degree,
degree_histogram,
desopo_pape_shortest_paths,
dfs_parents,
dfs_tree,
diameter,
dijkstra_shortest_paths,
eccentricity,
edges,
edgetype,
enumerate_paths,
floyd_warshall_shortest_paths,
has_edge,
has_path,
has_vertex,
induced_subgraph,
inneighbors,
is_connected,
is_cyclic,
is_directed,
is_strongly_connected,
is_weakly_connected,
johnson_shortest_paths,
kruskal_mst,
merge_vertices,
merge_vertices!,
mincut,
ne,
neighbors,
neighborhood,
neighborhood_dists,
nv,
outneighbors,
periphery,
prim_mst,
radius,
rem_edge!,
rem_vertex!,
reverse,
spfa_shortest_paths,
steiner_tree,
topological_sort_by_dfs,
tree,
vertices,
yen_k_shortest_paths

# TODO: Can we remove the dependency on `NamedGraphs`?
# Maybe need a `GraphExtensions.jl` or
# `GraphInterfaces.jl` package.
import NamedGraphs:
⊔,
boundary_edges,
boundary_vertices,
convert_vertextype,
directed_graph,
disjoint_union,
eccentricities,
incident_edges,
inner_boundary_vertices,
outer_boundary_vertices,
mincut_partitions,
rename_vertices,
symrcm,
symrcm_permute,
vertextype,
parent_graph,
parent_vertices_to_vertices

# General functions
not_implemented() = error("Not implemented")

include(joinpath("traits", "isunderlyinggraph.jl"))
include("utils.jl")
include("traits/isunderlyinggraph.jl")
include("abstractdatagraph.jl")
include("arrange.jl")
include("datagraph.jl")
# TODO: Turn into a weak dependency once `GraphsExtensions`
# is split off from `NamedGraphs`.
include("../ext/DataGraphsNamedGraphsExt/DataGraphsNamedGraphsExt.jl")

#
# exports
#

export DataGraph,
AbstractDataGraph,
directed_graph,
disjoint_union,
map_vertex_data,
map_edge_data,
map_data,
export AbstractDataGraph, DataGraph

end # module DataGraphs
using PackageExtensionCompat: @require_extensions
function __init__()
@require_extensions
end
end
Loading
Loading