pub struct Graph { /* private fields */ }Implementations§
Trait Implementations§
Source§impl GraphLike for Graph
impl GraphLike for Graph
Source§fn num_vertices(&self) -> usize
fn num_vertices(&self) -> usize
Number of vertices
Source§fn inputs_mut(&mut self) -> &mut Vec<V> ⓘ
fn inputs_mut(&mut self) -> &mut Vec<V> ⓘ
Mutable list of boundary vertices which serve as inputs
Source§fn set_inputs(&mut self, inputs: Vec<V>)
fn set_inputs(&mut self, inputs: Vec<V>)
Set inputs for the graph
Source§fn set_outputs(&mut self, outputs: Vec<V>)
fn set_outputs(&mut self, outputs: Vec<V>)
Set outputs for the graph
Source§fn outputs_mut(&mut self) -> &mut Vec<V> ⓘ
fn outputs_mut(&mut self) -> &mut Vec<V> ⓘ
Mutable list of boundary vertices which serve as outputs
Source§fn add_vertex(&mut self, ty: VType) -> V
fn add_vertex(&mut self, ty: VType) -> V
Add a vertex with the given type
Source§fn add_vertex_with_data(&mut self, d: VData) -> V
fn add_vertex_with_data(&mut self, d: VData) -> V
Add a vertex with the given VData struct
Source§fn add_named_vertex_with_data(&mut self, v: V, d: VData) -> Result<(), &str>
fn add_named_vertex_with_data(&mut self, v: V, d: VData) -> Result<(), &str>
Add a vertex with the given name and VData struct Read more
Source§fn remove_vertex(&mut self, v: V)
fn remove_vertex(&mut self, v: V)
Remove a vertex from a graph Read more
Source§fn add_edge_with_type(&mut self, s: V, t: V, ety: EType)
fn add_edge_with_type(&mut self, s: V, t: V, ety: EType)
Add an edge with the given type Read more
Source§fn vertex_data(&self, v: V) -> &VData
fn vertex_data(&self, v: V) -> &VData
Get the data associated to the given vertex
Source§fn vertex_data_opt(&self, v: V) -> Option<&VData>
fn vertex_data_opt(&self, v: V) -> Option<&VData>
Get the data associated to the given vertex, or None if it doesn’t exist
Source§fn vertex_data_mut(&mut self, v: V) -> &mut VData
fn vertex_data_mut(&mut self, v: V) -> &mut VData
Get a mutable ref to the data associated to the given vertex
Source§fn edge_type_opt(&self, s: V, t: V) -> Option<EType>
fn edge_type_opt(&self, s: V, t: V) -> Option<EType>
Returns type of an edge or None if the edge (or one of the vertices) doesn’t exist
Source§fn set_coord(&mut self, v: V, coord: impl Into<Coord>)
fn set_coord(&mut self, v: V, coord: impl Into<Coord>)
Sets the coordinate of a vertex Read more
Source§fn neighbors(&self, v: V) -> impl Iterator<Item = usize>
fn neighbors(&self, v: V) -> impl Iterator<Item = usize>
Returns an iterator over neighbors of a vertex
Source§fn incident_edges(&self, v: V) -> impl Iterator<Item = (usize, EType)>
fn incident_edges(&self, v: V) -> impl Iterator<Item = (usize, EType)>
Returns an iterator over pairs (v, t) for
v the “other end” of an edge,
and t its type.Source§fn scalar_mut(&mut self) -> &mut FScalar
fn scalar_mut(&mut self) -> &mut FScalar
Returns a mutable ref to the scalar associated with a ZX diagram
Source§fn find_edge<F>(&self, f: F) -> Option<(V, V, EType)>
fn find_edge<F>(&self, f: F) -> Option<(V, V, EType)>
Returns the first edge satisfying the given function, or None
Source§fn find_vertex<F>(&self, f: F) -> Option<V>
fn find_vertex<F>(&self, f: F) -> Option<V>
Returns the first vertex satisfying the given function, or None
fn contains_vertex(&self, v: V) -> bool
Source§fn scalar_factors(&self) -> impl Iterator<Item = (&Expr, &FScalar)>
fn scalar_factors(&self) -> impl Iterator<Item = (&Expr, &FScalar)>
Returns an iterator over all of the parametrised scalar factors Read more
Source§fn get_scalar_factor(&self, e: &Expr) -> Option<FScalar>
fn get_scalar_factor(&self, e: &Expr) -> Option<FScalar>
Get the scalar factor associated with a given boolean expression
Source§fn mul_scalar_factor(&mut self, e: Expr, s: FScalar)
fn mul_scalar_factor(&mut self, e: Expr, s: FScalar)
Insert (i.e. multiply) a new scalar factor
s^e into the overall scalarSource§fn pack(&mut self, force: bool)
fn pack(&mut self, force: bool)
This method can be called periodically to reduce wasted space in the graph representation Read more
Source§fn phase_and_vars(&self, v: V) -> (Phase, Parity)
fn phase_and_vars(&self, v: V) -> (Phase, Parity)
Returns the phase and any boolean variables at a vertex
Source§fn add_to_phase(&mut self, v: V, phase: impl Into<Phase>)
fn add_to_phase(&mut self, v: V, phase: impl Into<Phase>)
Adds a value to the phase of a vertex
Source§fn set_vertex_type(&mut self, v: V, ty: VType)
fn set_vertex_type(&mut self, v: V, ty: VType)
Sets the type of a vertex
Source§fn vertex_type(&self, v: V) -> VType
fn vertex_type(&self, v: V) -> VType
Returns the type of a vertex
Source§fn vertex_type_opt(&self, v: V) -> Option<VType>
fn vertex_type_opt(&self, v: V) -> Option<VType>
Returns type of a vertex or None if the vertex doesn’t exist
Source§fn set_vars(&mut self, v: V, vars: Parity)
fn set_vars(&mut self, v: V, vars: Parity)
Sets the boolean variables that affect the phase of this vertex Read more
Source§fn vars(&self, v: V) -> Parity
fn vars(&self, v: V) -> Parity
Returns the boolean variables that affect the phase of this vertex
Source§fn add_to_vars(&mut self, v: V, vars: &Parity)
fn add_to_vars(&mut self, v: V, vars: &Parity)
Adds the given variables to the parity expression of the vertex
Source§fn edge_type(&self, s: V, t: V) -> EType
fn edge_type(&self, s: V, t: V) -> EType
Returns the type of a given edge and panics if the edge doesn’t exist
Source§fn connected(&self, v0: V, v1: V) -> bool
fn connected(&self, v0: V, v1: V) -> bool
Returns true if the given vertices are connected Read more
Source§fn toggle_edge_type(&mut self, v0: V, v1: V)
fn toggle_edge_type(&mut self, v0: V, v1: V)
Turns H-edges into normal edges and vice-versa
Source§fn neighbor_vec(&self, v: V) -> Vec<V> ⓘ
fn neighbor_vec(&self, v: V) -> Vec<V> ⓘ
Returns a vector of the neighbours of a given vertex Read more
Source§fn incident_edge_vec(&self, v: V) -> Vec<(V, EType)>
fn incident_edge_vec(&self, v: V) -> Vec<(V, EType)>
Returns a vector of the incident edges of a given vertex Read more
Source§fn add_vertex_with_phase(&mut self, ty: VType, phase: impl Into<Phase>) -> V
fn add_vertex_with_phase(&mut self, ty: VType, phase: impl Into<Phase>) -> V
Add a vertex to the graph with the given type and phase
Source§fn add_edge_smart(&mut self, s: V, t: V, ety: EType)
fn add_edge_smart(&mut self, s: V, t: V, ety: EType)
Add an edge and simplify if necessary to remove parallel edges Read more
Source§fn plug_vertex(&mut self, v: V, b: BasisElem)
fn plug_vertex(&mut self, v: V, b: BasisElem)
Replace a boundary vertex with the given basis element Read more
Source§fn plug_output(&mut self, i: usize, b: BasisElem)
fn plug_output(&mut self, i: usize, b: BasisElem)
Plug the given basis vertex into the i-th output.
Source§fn plug_input(&mut self, i: usize, b: BasisElem)
fn plug_input(&mut self, i: usize, b: BasisElem)
Plug the given basis vertex into the i-th input.
Source§fn plug_inputs(&mut self, plug: &[BasisElem])
fn plug_inputs(&mut self, plug: &[BasisElem])
Plug the given list of normalised basis elements in as inputs, starting from the left Read more
Source§fn plug_outputs(&mut self, plug: &[BasisElem])
fn plug_outputs(&mut self, plug: &[BasisElem])
Plug the given list of normalised basis elements in as outputs, starting from the left Read more
Source§fn append_graph(&mut self, other: &impl GraphLike) -> FxHashMap<V, V>
fn append_graph(&mut self, other: &impl GraphLike) -> FxHashMap<V, V>
Appends the given graph to the current one, with fresh names. Read more
Source§fn plug(&mut self, other: &impl GraphLike)
fn plug(&mut self, other: &impl GraphLike)
Plug the given graph into the outputs and multiply scalars Read more
Source§fn is_identity(&self) -> bool
fn is_identity(&self) -> bool
Checks if the given graph only consists of wires from the inputs to outputs (in order)
Source§fn to_adjoint(&self) -> Self
fn to_adjoint(&self) -> Self
Same as GraphLike::adjoint(), but return as a copy
Source§fn subgraph_from_vertices(&self, verts: Vec<V>) -> Self
fn subgraph_from_vertices(&self, verts: Vec<V>) -> Self
Returns the full subgraph containing the given vertices
Source§fn copy(&self, adjoint: bool) -> Self
fn copy(&self, adjoint: bool) -> Self
Create a copy of the graph. If
adjoint is set,
the adjoint of the graph will be returned (inputs and outputs flipped, phases reversed).
The copy will have consecutive vertex indices, even if the original graph did not.Source§fn make_bipartite(&mut self)
fn make_bipartite(&mut self)
Performs inplace bipartite transformation of ZX graph by inserting opposite colored
spiders between same-colored neighbors
impl StructuralPartialEq for Graph
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more