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

change storage to Dict #9

Merged
merged 9 commits into from
May 18, 2020
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: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ version = "0.1.0"

[deps]
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
Multigraphs = "7ebac608-6c66-46e6-9856-b5f43e107bac"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
julia = "1.2"
Expand Down
24 changes: 6 additions & 18 deletions script/zx_plot.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using ZX
using Multigraphs
using LightGraphs
using GraphPlot: gplot
using Colors

function Multigraph2Graph(mg::Multigraph)
g = SimpleGraph(nv(mg))
vs = vertices(mg)
for me in edges(mg)
add_edge!(g, src(me), dst(me))
add_edge!(g, searchsortedfirst(vs, src(me)), searchsortedfirst(vs, dst(me)))
end
# multiplicities = ["$(mul(mg, src(e), dst(e)))" for e in edges(g)]
multiplicities = ["$(mg.adjmx[src(e), dst(e)])" for e in edges(g)]
multiplicities = ["$(mul(mg, vs[src(e)], vs[dst(e)]))" for e in edges(g)]
return g, multiplicities
end

ZX2Graph(zxd::ZXDiagram) = Multigraph2Graph(zxd.g)
ZX2Graph(zxd::ZXDiagram) = Multigraph2Graph(zxd.mg)

function st2color(S::SType)
S == Z && return colorant"green"
Expand All @@ -24,11 +24,11 @@ function st2color(S::SType)
S == Out && return colorant"gray"
end

ZX2nodefillc(zxd::ZXDiagram) = [st2color(zxd.st[v]) for v = 1:nv(zxd)]
ZX2nodefillc(zxd::ZXDiagram) = [st2color(zxd.st[v]) for v in vertices(zxd.mg)]

function ZX2nodelabel(zxd::ZXDiagram)
nodelabel = String[]
for v = 1:nv(zxd)
for v in vertices(zxd.mg)
zxd.st[v] == Z && push!(nodelabel, "$(zxd.ps[v]) π")
zxd.st[v] == X && push!(nodelabel, "$(zxd.ps[v]) π")
zxd.st[v] == H && push!(nodelabel, "H")
Expand All @@ -45,15 +45,3 @@ function ZXplot(zxd::ZXDiagram)
edgelabelc = colorant"black"
gplot(g, nodelabel = nodelabel, edgelabel = edgelabel, edgelabelc = edgelabelc, nodefillc = nodefillc)
end

g = Multigraph(6)
for e in [[1,3],[2,3],[3,4],[4,5],[4,6]]
add_edge!(g, e)
end
ps = [0, 0, 0//1, 0//1, 0, 0]
v_t = [In, Out, X, Z, Out, In]
zxd = ZXDiagram(g, v_t, ps)
ZXplot(zxd)

rule_b!(zxd, 4, 3)
ZXplot(zxd)
14 changes: 0 additions & 14 deletions src/Multigraphs/Multigraphs.jl

This file was deleted.

160 changes: 0 additions & 160 deletions src/Multigraphs/di_multigraph.jl

This file was deleted.

2 changes: 1 addition & 1 deletion src/Multigraphs/multigraph_adjlist.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LightGraphs, SparseArrays
using LightGraphs, SparseArrays, LinearAlgebra

import Base: copy
import LightGraphs: nv, has_edge, add_edge!, rem_edge!, rem_vertex!,
Expand Down
8 changes: 6 additions & 2 deletions src/ZX.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module ZX

include("Multigraphs/multiple_edge.jl")
include("Multigraphs/abstract_multigraph.jl")
include("Multigraphs/multigraph_adjlist.jl")
include("Multigraphs/multiple_edge_iter.jl")
include("zx_diagram.jl")
include("zx_graph.jl")
include("rules.jl")
# include("zx_graph.jl")
# include("rules.jl")

end # module
Loading