Struct Node

Source
pub struct Node(/* private fields */);
Expand description

A node or gate in a boolean circuit.

The inputs of the circuit are variables identified by their name. Other types of nodes are constant nodes or operations that have predecessors.

The clone operation only performs a shallow clone and thus allows sharing of nodes.

Implementations§

Source§

impl Node

Source

pub fn id(&self) -> usize

Returns an identifier for the node which is unique in the circuit but not stable across program reloads.

Source

pub fn operation(&self) -> &Operation

Returns the operation of the node.

Source

pub fn iter(&self) -> impl Iterator<Item = &Node>

Creates an iterator over the graph (the node itself and all its predecessors) that returns each node exactly once.

Source

pub fn post_visit_iter(&self) -> impl Iterator<Item = &Node>

Creates an iterator over the graph (the node itself and all its predecessors) with post-visit order, visiting each node exactly once. This means that the predecessors of each node are always visited before the node itself.

Source

pub fn to_string_as_tree(&self) -> String

Turns the node and its predecessors into a string representation, repeating shared nodes.

Source

pub fn try_to_constant(&self) -> Option<bool>

Returns the value of the node if it is a constant input node.

Source

pub fn gate_count(&self) -> (usize, usize)

Returns the number of variables and gates (nodes not counting variables or constants) in the circuit.

This depends on how the circuit was constructed, i.e. it does not deduplicate sub-circuits, but it does deduplicate variables with the same name.

Trait Implementations§

Source§

impl BitAnd for &Node

Source§

type Output = Node

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &Node) -> Node

Performs the & operation. Read more
Source§

impl BitAnd for Node

Source§

type Output = Node

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Node) -> Node

Performs the & operation. Read more
Source§

impl BitOr for &Node

Source§

type Output = Node

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &Node) -> Node

Performs the | operation. Read more
Source§

impl BitOr for Node

Source§

type Output = Node

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Node) -> Node

Performs the | operation. Read more
Source§

impl BitXor for &Node

Source§

type Output = Node

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &Node) -> Node

Performs the ^ operation. Read more
Source§

impl BitXor for Node

Source§

type Output = Node

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Node) -> Node

Performs the ^ operation. Read more
Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Literal> for Node

Source§

fn from(literal: &Literal) -> Node

Converts a literal to either a variable or a node that is the negation of a variable.

Source§

impl From<&str> for Node

Source§

fn from(name: &str) -> Node

Constructs a new node representing an input variable.

Two variables with the same name are considered equal, even if they are different node instances.

Source§

impl From<String> for Node

Source§

fn from(name: String) -> Node

Constructs a new node representing an input variable.

Two variables with the same name are considered equal, even if they are different node instances.

Source§

impl From<bool> for Node

Source§

fn from(value: bool) -> Node

Creates a constant node.

Source§

impl<'a> IntoIterator for &'a Node

Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator over the graph that returns each node exactly once.

Source§

type Item = &'a Node

The type of the elements being iterated over.
Source§

type IntoIter = GraphIterator<'a>

Which kind of iterator are we turning this into?
Source§

impl Not for &Node

Source§

type Output = Node

The resulting type after applying the ! operator.
Source§

fn not(self) -> Node

Performs the unary ! operation. Read more
Source§

impl Not for Node

Source§

type Output = Node

The resulting type after applying the ! operator.
Source§

fn not(self) -> Node

Performs the unary ! operation. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl !Send for Node

§

impl !Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.