APIs
Base.match
— Methodmatch(r, zxd)
Returns all matched vertices, which will be store in sturct Match
, for rule r
in a ZX-diagram zxd
.
Base.replace!
— Methodreplace!(r, zxd)
Match and replace with the rule r
.
Graphs.ne
— Methodne(zxd; count_mul = false)
Returns the number of edges of a ZX-diagram. If count_mul
, it will return the sum of multiplicities of all multiple edges. Otherwise, it will return the number of multiple edges.
Graphs.neighbors
— Methodneighbors(zxd, v; count_mul = false)
Returns a vector of vertices connected to v
. If count_mul
, there will be multiple copy for each vertex. Otherwise, each vertex will only appear once.
Graphs.nv
— Methodnv(zxd)
Returns the number of vertices (spiders) of a ZX-diagram.
ZXCalculus.ZX.add_spider!
— Methodadd_spider!(zxd, spider_type, phase = 0, connect = [])
Add a new spider which is of the type spider_type
with phase phase
and connected to the vertices connect
.
ZXCalculus.ZX.ancilla_extraction
— Methodancilla_extraction(zxg::ZXGraph) -> ZXDiagram
Extract a quantum circuit from a general ZXGraph
even without a gflow. It will introduce post-selection operators.
ZXCalculus.ZX.biadjacency
— Methodbiadjacency(zxg, F, N)
Return the biadjacency matrix of zxg
from vertices in F
to vertices in N
.
ZXCalculus.ZX.circuit_extraction
— Methodcircuit_extraction(zxg::ZXGraph)
Extract circuit from a graph-like ZX-diagram.
ZXCalculus.ZX.clifford_simplification
— Methodclifford_simplification(zxd)
Simplify zxd
with the algorithms in arXiv:1902.03178.
ZXCalculus.ZX.column_loc
— Methodcolumn_loc(layout, v)
Return the column number corresponding to the spider v
.
ZXCalculus.ZX.concat!
— Methodconcat!(zxd_1::ZXDiagram{T,P}, zxd_2::ZXDiagram{T,P})::ZXDiagram{T,P} where {T,P}
Appends two diagrams, where the second diagram is inverted
ZXCalculus.ZX.continued_fraction
— Methodcontinued_fraction(ϕ, n::Int) -> Rational
Obtain s
and r
from ϕ
that satisfies |s//r - ϕ| ≦ 1/2r²
ZXCalculus.ZX.gaussian_elimination
— Methodgaussian_elimination(M[, steps])
Return result and steps of Gaussian elimination of matrix M
. Here we assume that the elements of M
is in binary field F_2 = {0,1}.
ZXCalculus.ZX.get_input_idx
— Methodget_input_idx(zwd::ZXDiagram{T,P}, q::T) where {T,P}
Get spider index of input qubit q. Returns -1 if non-existant
ZXCalculus.ZX.get_inputs
— Methodget_inputs(zxd)
Returns a vector of input ids.
ZXCalculus.ZX.get_output_idx
— Methodget_output_idx(zxd::ZXDiagram{T,P}, q::T) where {T,P}
Get spider index of output qubit q. Returns -1 is non-existant
ZXCalculus.ZX.get_outputs
— Methodget_outputs(zxd)
Returns a vector of output ids.
ZXCalculus.ZX.import_edges!
— Methodimport_edges!(d1::ZXDiagram{T,P}, d2::ZXDiagram{T,P}, v2tov1::Dict{T,T}) where {T,P}
Import edges of d2 to d1, modify d1
ZXCalculus.ZX.import_non_in_out!
— Methodimport_non_in_out!(d1::ZXDiagram{T,P}, d2::ZXDiagram{T,P}, v2tov1::Dict{T,T}) where {T,P}
Add non input and output spiders of d2 to d1, modify d1. Record the mapping of vertex indices.
ZXCalculus.ZX.insert_spider!
— Methodinsert_spider!(zxd, v1, v2, spider_type, phase = 0)
Insert a spider of the type spider_type
with phase = phase
, between two vertices v1
and v2
. It will insert multiple times if the edge between v1
and v2
is a multiple edge. Also it will remove the original edge between v1
and v2
.
ZXCalculus.ZX.is_interior
— Methodis_interior(zxg::ZXGraph, v)
Return true
if v
is a interior spider of zxg
.
ZXCalculus.ZX.nqubits
— Methodnqubits(zxd)
Returns the qubit number of a ZX-diagram.
ZXCalculus.ZX.phase
— Methodphase(zxd, v)
Returns the phase of a spider. If the spider is not a Z or X spider, then return 0.
ZXCalculus.ZX.phase_teleportation
— Methodphase_teleportation(zxd)
Reducing T-count of zxd
with the algorithms in arXiv:1903.10477.
ZXCalculus.ZX.plot
— Methodplot(zxd::ZXDiagram{T, P}; kwargs...) where {T, P}
Plots a ZXDiagram using Vega.
If called from the REPL it will open in the Browser. Please remeber to run "using Vega, DataFrames" before, as this uses an extension
ZXCalculus.ZX.push_gate!
— Methodpush_gate!(zxd, ::Val{M}, locs...[, phase]; autoconvert=true)
Push an M
gate to the end of qubit loc
where M
can be :Z
, :X
, :H
, :SWAP
, :CNOT
and :CZ
. If M
is :Z
or :X
, phase
will be available and it will push a rotation M
gate with angle phase * π
. If autoconvert
is false
, the input phase
should be a rational numbers.
ZXCalculus.ZX.pushfirst_gate!
— Methodpushfirst_gate!(zxd, ::Val{M}, loc[, phase])
Push an M
gate to the beginning of qubit loc
where M
can be :Z
, :X
, :H
, :SWAP
, :CNOT
and :CZ
. If M
is :Z
or :X
, phase
will be available and it will push a rotation M
gate with angle phase * π
.
ZXCalculus.ZX.qubit_loc
— Methodqubit_loc(layout, v)
Return the qubit number corresponding to the spider v
.
ZXCalculus.ZX.rem_spider!
— Methodrem_spider!(zxd, v)
Remove a spider indexed by v
.
ZXCalculus.ZX.rem_spiders!
— Methodrem_spiders!(zxd, vs)
Remove spiders indexed by vs
.
ZXCalculus.ZX.rewrite!
— Methodrewrite!(r, zxd, matches)
Rewrite a ZX-diagram zxd
with rule r
for all vertices in matches
. matches
can be a vector of Match
or just an instance of Match
.
ZXCalculus.ZX.round_phases!
— Methodround_phases!(zxd)
Round phases between [0, 2π).
ZXCalculus.ZX.scalar
— Methodscalar(zxd)
Returns the scalar of zxd
.
ZXCalculus.ZX.set_column!
— Methodset_qubit!(layout, v, q)
Set the column number of the spider v
.
ZXCalculus.ZX.set_loc!
— Methodset_loc!(layout, v, q, col)
Set the location of the spider v
.
ZXCalculus.ZX.set_phase!
— Methodset_phase!(zxd, v, p)
Set the phase of v
in zxd
to p
.
ZXCalculus.ZX.set_qubit!
— Methodset_qubit!(layout, v, q)
Set the qubit number of the spider v
.
ZXCalculus.ZX.simplify!
— Methodsimplify!(r, zxd)
Simplify zxd
with the rule r
.
ZXCalculus.ZX.spider_type
— Methodspider_type(zxd, v)
Returns the spider type of a spider.
ZXCalculus.ZX.stype_to_val
— Methodstype_to_val(st)::Union{SpiderType,nothing}
Converts SpiderType into Val
ZXCalculus.ZX.tcount
— Methodtcount(zxd)
Returns the T-count of a ZX-diagram.
ZXCalculus.ZX.update_frontier!
— Methodupdate_frontier!(zxg, frontier, qubit_map, cir)
Update frontier. This is an important step in the circuit extraction algorithm. For more detail, please check the paper arXiv:1902.03178.
ZXCalculus.ZX.verify_equality
— Methodverify_equality(zxd_1::ZXDiagram, zxd_2::ZXDiagram)
checks the equivalence of two different ZXDiagrams
ZXCalculus.ZX.GEStep
— TypeGEStep
A struct for representing steps in the Gaussian elimination.
ZXCalculus.ZX.Match
— TypeMatch{T<:Integer}
A struct for saving matched vertices.
ZXCalculus.ZX.Rule
— TypeRule{L}
The struct for identifying different rules.
Rule for ZXDiagram
s:
Rule{:f}()
: rule fRule{:h}()
: rule hRule{:i1}()
: rule i1Rule{:i2}()
: rule i2Rule{:pi}()
: rule πRule{:c}()
: rule c
Rule for ZXGraph
s:
Rule{:lc}()
: local complementary ruleRule{:p1}()
: pivoting ruleRule{:pab}()
: rule for removing Pauli spiders adjancent to boundary spidersRule{:p2}()
: rule p2Rule{:p3}()
: rule p3Rule{:id}()
: rule idRule{:gf}()
: gadget fushion rule
ZXCalculus.ZX.ZXDiagram
— TypeZXDiagram{T, P}
This is the type for representing ZX-diagrams.
ZXCalculus.ZX.ZXDiagram
— MethodZXDiagram(nbits)
Construct a ZXDiagram of a empty circuit with qubit number nbit
julia> zxd = ZXDiagram(3)
ZX-diagram with 6 vertices and 3 multiple edges:
(S_1{input} <-1-> S_2{output})
(S_3{input} <-1-> S_4{output})
(S_5{input} <-1-> S_6{output})
ZXCalculus.ZX.ZXDiagram
— MethodZXDiagram(mg::Multigraph{T}, st::Dict{T, SpiderType.SType}, ps::Dict{T, P},
layout::ZXLayout{T} = ZXLayout{T}(),
phase_ids::Dict{T,Tuple{T, Int}} = Dict{T,Tuple{T,Int}}()) where {T, P}
ZXDiagram(mg::Multigraph{T}, st::Vector{SpiderType.SType}, ps::Vector{P},
layout::ZXLayout{T} = ZXLayout{T}()) where {T, P}
Construct a ZXDiagram with all information.
julia> using Graphs, Multigraphs, ZXCalculus.ZX;
julia> using ZXCalculus.ZX.SpiderType: In, Out, H, Z, X;
julia> mg = Multigraph(5);
julia> for i = 1:4
add_edge!(mg, i, i+1)
end;
julia> ZXDiagram(mg, [In, Z, H, X, Out], [0//1, 1, 0, 1//2, 0])
ZX-diagram with 5 vertices and 4 multiple edges:
(S_1{input} <-1-> S_2{phase = 1//1⋅π})
(S_2{phase = 1//1⋅π} <-1-> S_3{H})
(S_3{H} <-1-> S_4{phase = 1//2⋅π})
(S_4{phase = 1//2⋅π} <-1-> S_5{output})
ZXCalculus.ZX.ZXGraph
— TypeZXGraph{T, P}
This is the type for representing the graph-like ZX-diagrams.
ZXCalculus.ZX.ZXGraph
— MethodZXGraph(zxd::ZXDiagram)
Convert a ZX-diagram to graph-like ZX-diagram.
julia> using ZXCalculus.ZX
julia> zxd = ZXDiagram(2); push_gate!(zxd, Val{:CNOT}(), 2, 1);
julia> zxg = ZXGraph(zxd)
ZX-graph with 6 vertices and 5 edges:
(S_1{input} <-> S_5{phase = 0//1⋅π})
(S_2{output} <-> S_5{phase = 0//1⋅π})
(S_3{input} <-> S_6{phase = 0//1⋅π})
(S_4{output} <-> S_6{phase = 0//1⋅π})
(S_5{phase = 0//1⋅π} <-> S_6{phase = 0//1⋅π})
ZXCalculus.ZX.ZXLayout
— TypeZXLayout
A struct for the layout information of ZXDiagram
and ZXGraph
.
Base.match
— Methodmatch(r, zxwd)
Returns all matched vertices, which will be store in sturct Match
, for rule r
in a ZXW-diagram zxwd
.
Base.match
— MethodRule that implements both f and s1 rule.
Graphs.ne
— Methodne(zxwd; count_mul = false)
Returns the number of edges of a ZXW-diagram. If count_mul
, it will return the sum of multiplicities of all multiple edges. Otherwise, it will return the number of multiple edges.
Graphs.neighbors
— Methodneighbors(zxwd, v; count_mul = false)
Returns a vector of vertices connected to v
. If count_mul
, there will be multiple copy for each vertex. Otherwise, each vertex will only appear once.
Graphs.nv
— Methodnv(zxwd)
Returns the number of vertices (spiders) of a ZXW-diagram.
ZXCalculus.ZX.push_gate!
— Methodpush_gate!(zxwd, ::Val{M}, locs...[, phase]; autoconvert=true)
Push an M
gate to the end of qubit loc
where M
can be :Z
, :X
, :H
, :SWAP
, :CNOT
and :CZ
. If M
is :Z
or :X
, phase
will be available and it will push a rotation M
gate with angle phase * π
. If autoconvert
is false
, the input phase
should be a rational numbers.
ZXCalculus.ZX.pushfirst_gate!
— Methodpushfirst_gate!(zxwd, ::Val{M}, loc[, phase])
Push an M
gate to the beginning of qubit loc
where M
can be :Z
, :X
, :H
, :SWAP
, :CNOT
and :CZ
. If M
is :Z
or :X
, phase
will be available and it will push a rotation M
gate with angle phase * π
.
ZXCalculus.ZX.rem_spider!
— Methodrem_spider!(zxwd, v)
Remove a spider indexed by v
.
ZXCalculus.ZX.rem_spiders!
— Methodrem_spiders!(zxwd, vs)
Remove spiders indexed by vs
.
ZXCalculus.ZX.rewrite!
— Methodrewrite!(r, zxd, matches)
Rewrite a ZX-diagram zxd
with rule r
for all vertices in matches
. matches
can be a vector of Match
or just an instance of Match
.
ZXCalculus.ZXW.add_inout!
— MethodAdd input and outputs to diagram
ZXCalculus.ZXW.add_spider!
— Methodadd_spider!(zxwd, spider, connect = [])
Add a new spider spider
with appropriate parameter connected to the vertices connect
.
ZXCalculus.ZXW.concat!
— MethodConcatenate two ZXWDiagrams, modify d1.
Remove outputs of d1 and inputs of d2. Then add edges between to vertices that was conntecting to outputs of d1 and inputs of d2. Assuming you don't concatenate two empty circuit ZXWDiagram
ZXCalculus.ZXW.dagger
— MethodConvert ZXWDiagram that represents unitary U to U^†
ZXCalculus.ZXW.expval_circ!
— MethodConstruct ZXW Diagram for representing the expectation value circuit
ZXCalculus.ZXW.get_inputs
— Methodget_inputs(zxwd)
Returns a vector of input ids.
ZXCalculus.ZXW.get_outputs
— Methodget_outputs(zxwd)
Returns a vector of output ids.
ZXCalculus.ZXW.import_edges!
— MethodImport edges of d2 to d1, modify d1
ZXCalculus.ZXW.import_non_in_out!
— MethodAdd non input and output spiders of d2 to d1, modify d1. Record the mapping of vertex indices.
ZXCalculus.ZXW.insert_spider!
— Methodinsert_spider!(zxwd, v1, v2, spider)
Insert a spider spider
with appropriate parameter, between two vertices v1
and v2
. It will insert multiple times if the edge between v1
and v2
is a multiple edge. Also it will remove the original edge between v1
and v2
.
ZXCalculus.ZXW.insert_wtrig!
— MethodInsert W triangle on a vector of vertices
ZXCalculus.ZXW.int_prep!
— MethodPrepare spider at loc for integration.
Perform the simplified step of zeroing out phase of spider and readying it for integration
- If target spider is X spider, turn it to Z by adding H to all its legs
- Pull out the Phase of the spider
- zero out the phase
- change the current spider back to its original type if necessary,
will generate one extra H spider.
ZXCalculus.ZXW.integrate!
— MethodIntegrate two pairs of +/- parameter. Theorem 23 of https://arxiv.org/abs/2201.13250
ZXCalculus.ZXW.nout
— Methodnout(zxwd)
Returns the number of outputs of a ZXW-diagram
ZXCalculus.ZXW.nqubits
— Methodnqubits(zxwd)
Returns the qubit number of a ZXW-diagram.
ZXCalculus.ZXW.parameter
— Methodparameter(zxwd, v)
Returns the parameter of a spider. If the spider is not a Z or X spider, then return 0.
ZXCalculus.ZXW.print_spider
— Methodprint_spider(io, zxwd, v)
Print a spider to io
.
ZXCalculus.ZXW.round_phases!
— Methodround_phases!(zxwd)
Round phases between [0, 2π).
ZXCalculus.ZXW.set_phase!
— Methodset_phase!(zxwd, v, p)
Set the phase of v
in zxwd
to p
. If v
is not a Z or X spider, then do nothing. If v
is not in zxwd
, then return false to indicate failure.
ZXCalculus.ZXW.spider_type
— Methodspider_type(zxwd, v)
Returns the spider type of a spider if it exists.
ZXCalculus.ZXW.stack_zxwd!
— MethodStacking two ZXWDiagrams in place. Modify d1.
Performs tensor product of two ZXWDiagrams. The result is a ZXWDiagram with d1 on lower qubit indices. Assuming number of inputs and outputs of are the same for both d1 and d2.
ZXCalculus.ZXW.substitute_variables!
— MethodReplace symbols in ZXW Diagram with specific values
ZXCalculus.ZXW.symbol_vertices
— MethodFinds vertices of Spider that contains the parameter θ or -θ
Graphs.SimpleGraphs.add_edge!
— MethodGraphs.add_edge!(zwd::ZWDiagram, he, mul)
Add mul
of edges that connects vertices with already connected with edgex
.
Graphs.SimpleGraphs.rem_edge!
— Methodrem_edge!(zwd::ZWDiagram, x)
Remove Edge with indices x
.
Graphs.ne
— Methodne(zwd)
Returns the number of edges of a ZW-diagram.
Graphs.neighbors
— Methodneighbors(zwd, v)
Returns a vector of vertices connected to v
.
Graphs.nv
— Methodnv(zwd)
Returns the number of vertices (spiders) of a ZW-diagram.
ZXCalculus.ZW.add_spider!
— Methodadd_spider!(zwd, spider, connect = [])
Add a new spider spider
with appropriate parameter connected to the half edges connect
.
Had to make halfedge class 1 citizen because there will be ambiguity Consider A to B and there are multiple edges to A and from A to B
ZXCalculus.ZW.get_input_idx
— Methodget_input_idx(zwd::ZXWDiagram{T,P}, q::T) where {T,P}
Get spider index of input qubit q.
ZXCalculus.ZW.get_inputs
— Methodget_inputs(zwd)
Returns a vector of input ids.
ZXCalculus.ZW.get_output_idx
— Methodget_output_idx(zwd::ZWDiagram{T,P}, q::T) where {T,P}
Get spider index of output qubit q.
ZXCalculus.ZW.get_outputs
— Methodget_outputs(zwd)
Returns a vector of output ids.
ZXCalculus.ZW.insert_spider!
— Methodinsert_spider!(zwd, he1, spider)
Insert a spider spider
with appropriate parameter on the half-edge prior to he1
. v1 <- he1 - v2 becomes v1 <- he1 - v2 <- henew - vnew
ZXCalculus.ZW.nout
— Methodnout(zwd)
Returns the number of outputs of a ZW-diagram
ZXCalculus.ZW.nqubits
— Methodnqubits(zwd)
Returns the qubit number of a ZW-diagram.
ZXCalculus.ZW.parameter
— Methodparameter(zwd, v)
Returns the parameter of a spider. If the spider is not a monoZ or binZ spider, then return 0.
ZXCalculus.ZW.print_spider
— Methodprint_spider(io, zwd, v)
Print a spider to io
.
ZXCalculus.ZW.round_phases!
— Methodround_phases!(zwd)
Round phases between [0, 2π).
ZXCalculus.ZW.set_phase!
— Methodset_phase!(zwd, v, p)
Set the phase of v
in zwd
to p
. If v
is not a monoZ or binZ spider, then do nothing. If v
is not in zwd
, then return false to indicate failure.
ZXCalculus.ZW.spider_type
— Methodspider_type(zwd, v)
Returns the spider type of a spider if it exists.
ZXCalculus.ZX.spiders
— Methodspiders(zwd::ZWDiagram)
Returns a vector of spider idxs.
ZXCalculus.ZW.ZWDiagram
— MethodZWDiagram(nbits::T, ::Type{P}) where {T<:Integer}
Create a ZW-diagram with nbits
input and output qubits.
Scalar is parameterized to be P
.
ZXCalculus.Utils.Parameter
— TypeParameter
The Algebraic Data Type for representing parameter related to spider. PiUnit(x)
represents the the phase of a number exp(im*x*π)
. Factor(x)
represents a number x
.
ZXCalculus.Utils.Parameter
— MethodParameter Constructors for Parameter
type.
ZXCalculus.Utils.Phase
— TypePhase
The type supports manipulating phases as expressions. Phase(x)
represents the number x⋅π
.
ZXCalculus.Utils.Scalar
— TypeScalar
A struct for recording the scalars when we rewrite ZX-diagrams.
ZXCalculus.PMG.add_facet_to_boarder!
— Methodadd_facet_to_boarder!(pmg::PlanarMultigraph{T}, h::T, g::T) where {T<:Integer}
Creates a facet with edge connecting the destination of h and g.
h and g needs to be in ccw order
Reference
ZXCalculus.PMG.add_vertex_and_facet_to_boarder!
— Methodadd_vertex_and_facet_to_boarder!(
pmg::PlanarMultigraph{T},
h::T,
g::T,
) where {T<:Integer}
TBW
Reference
ZXCalculus.PMG.create_edge!
— Methodcreate_edge!(pmg::PlanarMultigraph{T}, vs::T, vd::T) where {T<:Integer}
Create an a pair of halfedge from vs to vd, add to PlanarMultigraph pmg. Facet information is not updated yet but set to default value of 0. Vertex to halfedge is updated and set to the two newly added half edges.
ZXCalculus.PMG.create_face!
— Methodcreate_face!(pmg::PlanarMultigraph{T}) where {T<:Integer}
ZXCalculus.PMG.create_vertex!
— Methodcreate_vertex!(g::PlanarMultigraph{T}; mul::Int = 1) where {T<:Integer}
Create vertices.
Create mul
of vertices and record them in PlanarMultigraph g's v_max
field.
ZXCalculus.PMG.erase_facet!
— MethodZXCalculus.PMG.gc_vertex!
— Methodgc_vertex!(pmg::PlanarMultigraph{T}, vs::Vector{T}) where {T<:Integer}
Garbage collect vertices that's no longer connected to any edge.
ZXCalculus.PMG.is_boundary
— Methodis_boundary(g::PlanarMultigraph{T}, he_id::T) where {T}
If the half edge is on the boundary of entire manifold
ZXCalculus.PMG.join_facet!
— Methodjoin_facet!(pmg::PlanarMultigraph{T}, h::T) where {T}
Join two facets incident to h and it's twin into one.
The facet incident to h's twin is removed.
ZXCalculus.PMG.join_vertex!
— Methodjoin_vertex!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}
Join two vertices connected by a HalfEdge into one.
Provides the removal of an edge.
ZXCalculus.PMG.make_hole!
— Methodmake_hole!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}
Convert the facet incident to a half edge into a hole.
Makes all the half edges in the facet a boundary halfedge.
Reference
ZXCalculus.PMG.n_conn_comp
— Methodn_conn_comp(g::PlanarMultigraph)
Return the number of connected components.
ZXCalculus.PMG.new_edge
— Methodnew_edge(src::T, dst::T) where {T<:Integer}
Create a half edge and its twin
ZXCalculus.PMG.out_half_edge
— Methodout_half_edge(g::PlanarMultigraph{T}, v::T)
Get the one out half edge of a vertex
ZXCalculus.PMG.prev
— Methodprev(g::PlanarMultigraph{T}, he_id::T) where {T<:Integer}
Provides Previous Half Edge of a facet. HDS is bidi
ZXCalculus.PMG.split_edge!
— Methodsplit_edge!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}
Split an edge into two consecutive ones. 1->2->3 becomes 1->4->2->3
ZXCalculus.PMG.split_facet!
— Methodsplit_facet!(pmg::PlanarMultigraph{T}, h::T, g::T) where {T<:Integer}
Split a facet incident to h and g into two facets.
Precondition
- h and g are in the same facet
- h and g are not the same half edge
- Cannot be used to split the faces incident to the multiedge.
ZXCalculus.PMG.split_vertex!
— Methodsplit_vertex!(g::PlanarMultigraph{T}, he1::T, he2::T) where {T<:Integer}
Split a vertex into 2 vertices.
Connect the two vertices with a new pair of half edges. he1 and he2 are half edges that marks the start and end of half edges that remain on v1.
After splitting, h points to the newly added vertex
Reference
ZXCalculus.PMG.surrounding_half_edge
— Methodsurrounding_half_edge(g::PlanarMultigraph{T}, f::T)
Get the one surrounding half edge of a face
ZXCalculus.PMG.trace_face
— Methodtrace_face(g::PlanarMultigraph{T}, f::T; safe_trace = false) where {T}
Return the half edges of a face.
If safe_trace
is true, then the half edges are returned in scrambled order. Otherwise, the returned half edges are in counter clockwise order but is not guaranteed to be consitent with he2f.
ZXCalculus.PMG.σ
— Methodσ(g::PlanarMultigraph{T}, he_id::T) where {T}
Get prevatsource
ZXCalculus.PMG.σ_inv
— Methodσ_inv(pmg::PlanarMultigraph{T}, h::T) where {T}
Get nextatsource, clockwise
ZXCalculus.PMG.ϕ
— Methodϕ(g::PlanarMultigraph{T}, he_id::T) where {T}
Get twin half edge id
ZXCalculus.PMG.HalfEdge
— TypeHalfEdge{T<:Integer}(src ,dst)
Datatype to represent a Half Edge
Reference
- Brönnimann, Hervé [Designing and Implementing a General Purpose Halfedge Data Structure]
(https://doi.org/10.1007/3-540-44688-5_5)
ZXCalculus.PMG.PlanarMultigraph
— TypePlanarMultigraph{T<:Integer}
Implements a planar multigraph with a maximal HDS Structure.
Features
- Stores Forward Half Edge pointer in facet
- Vertex linked
- Face Linked
References:
Our implementation is based heavily on the CGAL Library. A good introduction on the HDS Structure and the Polyhedron3 Object which gives the boundary representation of a 2-manifold can be found in this paper.
TODO: Proof of Completeness for Euler Operations with Preconditions In the
CGAL Library, the Euler Operations are implemented with preconditions. It was pointed out that Euler Operations are closed for orientable 2-manifolds in paper where the detailed proof is in book. It was further pointed out in paper that Euler Operations are complete in Theorem 4.4.
The question remains whether the completeness remains for the preconditions attached. One way of proving is to show that for the Euler Operations used in Theorem 4.4, we could always construct them out of the Euler Operations in CGAL Library with preconditions?