Skip to content

Simplify types #4

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

Merged
merged 10 commits into from
Nov 30, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
/docs/build/
benchmark/*.json
docs/build/
Manifest.toml
test/Manifest.toml
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name = "DataGraphs"
uuid = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org> and contributors"]
version = "0.0.1"
version = "0.1.0"

[deps]
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
MultiDimDictionaries = "87ff4268-a46e-478f-b30a-76b83dd64e3c"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"

[compat]
Dictionaries = "0.3"
Graphs = "1"
MultiDimDictionaries = "0.0.1"
NamedGraphs = "0.0.1"
SimpleTraits = "0.9.4"
NamedGraphs = "0.1.1"
SimpleTraits = "0.9"
julia = "1.7"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion examples/datagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Dictionaries
using Graphs

g = grid((4,))
dg = DataGraph{String,Symbol}(g)
dg = DataGraph(g, String, Symbol)
@show !isassigned(dg, Edge(1, 2))
@show !isassigned(dg, 1 => 2)
@show !isassigned(dg, Edge(1 => 2))
Expand Down
84 changes: 0 additions & 84 deletions examples/deprecated/datagraph.jl

This file was deleted.

135 changes: 0 additions & 135 deletions examples/deprecated/multidimdatagraph_2d.jl

This file was deleted.

32 changes: 5 additions & 27 deletions examples/disjoint_union.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Graphs
using NamedGraphs
using DataGraphs

g = NamedDimDataGraph{String,String}(grid((2, 2)); dims=(2, 2))
g = DataGraph(named_grid((2, 2)), String, String)

for v in vertices(g)
g[v] = "V$v"
Expand All @@ -13,31 +13,9 @@ end

gg = g ⊔ g

@show has_vertex(gg, 1, 1, 1)
@show has_vertex(gg, 2, 1, 1)
@show has_edge(gg, (1, 1, 1) => (1, 1, 2))
@show has_edge(gg, (2, 1, 1) => (2, 1, 2))
@show nv(gg) == 2nv(g)
@show ne(gg) == 2ne(g)

gg = [g; g]

@show has_vertex(gg, 1, 1)
@show has_vertex(gg, 2, 1)
@show has_vertex(gg, 3, 1)
@show has_vertex(gg, 4, 1)
@show has_edge(gg, (1, 1) => (1, 2))
@show has_edge(gg, (3, 1) => (3, 2))
@show nv(gg) == 2nv(g)
@show ne(gg) == 2ne(g)

gg = [g;; g]

@show has_vertex(gg, 1, 1)
@show has_vertex(gg, 1, 2)
@show has_vertex(gg, 1, 3)
@show has_vertex(gg, 1, 4)
@show has_edge(gg, (1, 1) => (1, 2))
@show has_edge(gg, (1, 3) => (1, 4))
@show has_vertex(gg, ((1, 1), 1))
@show has_vertex(gg, ((1, 1), 2))
@show has_edge(gg, ((1, 1), 1) => ((1, 2), 1))
@show has_edge(gg, ((1, 1), 2) => ((1, 2), 2))
@show nv(gg) == 2nv(g)
@show ne(gg) == 2ne(g)
15 changes: 7 additions & 8 deletions examples/multidimdatagraph_1d.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using DataGraphs
using Graphs
using MultiDimDictionaries
using NamedGraphs

g = NamedDimGraph(grid((4,)), ["A", "B", "C", "D"])
dg = NamedDimDataGraph{String,Symbol}(g)
g = NamedGraph(grid((4,)), ["A", "B", "C", "D"])
dg = DataGraph(g, String, Symbol)

@show has_vertex(dg, "A")
@show has_vertex(dg, "D")
Expand All @@ -21,9 +20,9 @@ dg = NamedDimDataGraph{String,Symbol}(g)
@show !isassigned(dg, "C")
@show !isassigned(dg, "D")

@show !isassigned(dg, NamedDimEdge("A", "B"))
@show !isassigned(dg, NamedEdge("A", "B"))
@show !isassigned(dg, "A" => "B")
@show !isassigned(dg, NamedDimEdge("A" => "B"))
@show !isassigned(dg, NamedEdge("A" => "B"))
@show !isassigned(dg, "A" => "C")

dg["A"] = "V1"
Expand All @@ -42,9 +41,9 @@ dg["D"] = "V4"

dg["A" => "B"] = :E12
dg["B" => "C"] = :E23
dg[NamedDimEdge("C", "D")] = :E34
@show isassigned(dg, NamedDimEdge("B", "C"))
dg[NamedEdge("C", "D")] = :E34
@show isassigned(dg, NamedEdge("B", "C"))
@show isassigned(dg, "C" => "D")
@show dg[NamedDimEdge("A", "B")] == :E12
@show dg[NamedEdge("A", "B")] == :E12
@show dg["B" => "C"] == :E23
@show dg["C" => "D"] == :E34
41 changes: 4 additions & 37 deletions examples/multidimdatagraph_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ using NamedGraphs
using Dictionaries
using Graphs

g = NamedDimGraph(grid((2, 2)); dims=(2, 2))
dg = NamedDimDataGraph{String,String}(g)
g = named_grid((2, 2))
dg = DataGraph(g, String, String)

dg[1, 1] = "X11"

Expand All @@ -15,40 +15,7 @@ dg[(1, 1) => (1, 2)] = "X11↔X12"
@show dg[(1, 1) => (1, 2)] == "X11↔X12"
@show dg[(1, 2) => (1, 1)] == "X11↔X12"

# XXX: Broken
#@show isassigned(dg, (1, 1))
#@show isassigned(dg, 1, 1)

@show isassigned(dg, NamedDimEdge((1, 1), (1, 2)))
@show !isassigned(dg, NamedDimEdge((1, 1), (2, 2)))
@show isassigned(dg, NamedEdge((1, 1), (1, 2)))
@show !isassigned(dg, NamedEdge((1, 1), (2, 2)))
@show isassigned(dg, (1, 1) => (1, 2))
@show !isassigned(dg, (1, 1) => (2, 2))

## @show has_edge(dg, 1, 2)
## @show has_edge(dg, 1 => 2)
## @show !has_edge(dg, 1, 3)
## @show !has_edge(dg, 1 => 3)
## @show has_vertex(dg, 1)
## @show has_vertex(dg, 4)
## @show !has_vertex(dg, 0)
## @show !has_vertex(dg, 5)
##
## dg[1] = "V1"
## dg[2] = "V2"
## dg[3] = "V3"
## dg[4] = "V4"
## @show isassigned(dg, 1)
## @show dg[1] == "V1"
## @show dg[2] == "V2"
## @show dg[3] == "V3"
## @show dg[4] == "V4"
##
## dg[1 => 2] = :E12
## dg[2 => 3] = :E23
## dg[Edge(3, 4)] = :E34
## #@show isassigned(dg, (1, 2))
## @show isassigned(dg, Edge(2, 3))
## @show isassigned(dg, 3 => 4)
## @show dg[Edge(1, 2)] == :E12
## @show dg[2 => 3] == :E23
## @show dg[3 => 4] == :E34
Loading