# aigverse.networks

Provides logic network data structures and derived views.

This module includes network types, edge and index list utilities, and helper
objects for structural manipulation.

## Module Contents

### *class* NodeTensorEncoding(\*args, \*\*kwds)

Bases: [`enum.Enum`](https://docs.python.org/3/library/enum.html#enum.Enum)

Node encoding mode for exported graph tensors.

All node features use float32; only the categorical encoding scheme changes.
- INTEGER: Node classes are scalar labels in the first feature column.
- ONE_HOT: Node classes are one-hot vectors in [constant, pi, gate, po] order.

#### INTEGER *= 0*

0=constant, 1=pi, 2=gate, 3=po.

* **Type:**
  Scalar node labels in the first feature column

#### ONE_HOT *= 1*

One-hot node labels in [constant, pi, gate, po] order.

### *class* EdgeTensorEncoding(\*args, \*\*kwds)

Bases: [`enum.Enum`](https://docs.python.org/3/library/enum.html#enum.Enum)

Edge encoding mode for exported graph tensors.

All edge features use float32; only the categorical encoding scheme changes.
- BINARY: Edge polarity is binary (regular=0.0, inverted=1.0).
- SIGNED: Edge polarity is signed (regular=+1.0, inverted=-1.0).
- ONE_HOT: Edge polarity is one-hot in [regular, inverted] order.

#### BINARY *= 0*

Labels are encoded as 0.0 (regular) and 1.0 (inverted).

#### SIGNED *= 1*

Labels are encoded as +1.0 (regular) and -1.0 (inverted).

#### ONE_HOT *= 2*

One-hot edge labels in [regular, inverted] order.

### *class* AigSignal(index: [int](https://docs.python.org/3/builtins/functions.html#int), complement: [bool](https://docs.python.org/3/builtins/functions.html#bool))

Represents a signal in an AIG.

Signals point to nodes and may be complemented.

#### *property* index *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Node index referenced by the signal.

#### *property* complement *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether this signal is complemented.

#### *property* data *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Raw packed signal representation.

#### \_\_hash_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns a hash value for dictionary/set usage.

#### \_\_eq_\_(other: [object](https://docs.python.org/3/builtins/functions.html#object)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether two signals are equal.

* **Parameters:**
  **other** – Object to compare.
* **Returns:**
  `True` if equal, otherwise `False`.

#### \_\_ne_\_(other: [object](https://docs.python.org/3/builtins/functions.html#object)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether two signals are not equal.

* **Parameters:**
  **other** – Object to compare.
* **Returns:**
  `True` if not equal, otherwise `False`.

#### \_\_lt_\_(other: [AigSignal](#aigverse.networks.AigSignal)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether this signal is ordered before another signal.

#### \_\_invert_\_() → [AigSignal](#aigverse.networks.AigSignal)

Returns the complemented signal.

#### \_\_pos_\_() → [AigSignal](#aigverse.networks.AigSignal)

Returns a normalized positive-phase signal.

#### \_\_neg_\_() → [AigSignal](#aigverse.networks.AigSignal)

Returns a normalized negative-phase signal.

#### \_\_xor_\_(complement: [bool](https://docs.python.org/3/builtins/functions.html#bool)) → [AigSignal](#aigverse.networks.AigSignal)

XORs the signal phase with a Boolean complement bit.

* **Parameters:**
  **complement** – Complement bit to XOR with the current signal phase.
* **Returns:**
  A phase-adjusted signal.

### *class* Aig

### *class* Aig(ntk: [Aig](#aigverse.networks.Aig))

Represents an AIG and its structural operations.

#### NOTE
to_index_list() keeps combinational structure only.
Augmented view metadata is not preserved.

#### clone() → [Aig](#aigverse.networks.Aig)

Creates a structural copy of the network.

#### *property* size *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of nodes in the network.

#### *property* num_gates *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of logic gates in the network.

#### *property* num_pis *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary inputs.

#### *property* num_pos *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary outputs.

#### get_node(s: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the node referenced by a signal.

#### make_signal(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a signal from a node.

#### is_complemented(s: [AigSignal](#aigverse.networks.AigSignal)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether a signal is complemented.

#### node_to_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the integer index of a node.

#### index_to_node(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the node for an index.

#### pi_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the primary-input position of a node.

#### pi_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the primary input node at `index`.

#### po_index(s: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the primary-output position of a signal.

#### po_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigSignal](#aigverse.networks.AigSignal)

Returns the primary output signal at `index`.

#### get_constant(value: [bool](https://docs.python.org/3/builtins/functions.html#bool)) → [AigSignal](#aigverse.networks.AigSignal)

Returns the constant signal for a Boolean value.

#### create_pi() → [AigSignal](#aigverse.networks.AigSignal)

Creates and returns a new primary input signal.

#### create_po(f: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Creates a primary output from signal `f`.

#### *property* is_combinational *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether the network is combinational.

#### create_buf(a: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a buffer.

#### create_not(a: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an inversion.

#### create_and(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an AND.

#### create_nand(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a NAND.

#### create_or(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an OR.

#### create_nor(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a NOR.

#### create_xor(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an XOR.

#### create_xnor(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an XNOR.

#### create_lt(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a less-than comparator.

#### create_le(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a less-or-equal comparator.

#### create_maj(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal), c: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a majority.

#### create_ite(cond: [AigSignal](#aigverse.networks.AigSignal), f_then: [AigSignal](#aigverse.networks.AigSignal), f_else: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates an if-then-else.

#### create_xor3(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal), c: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Creates a 3-input XOR.

#### create_nary_and(fs: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigSignal](#aigverse.networks.AigSignal)]) → [AigSignal](#aigverse.networks.AigSignal)

Creates an n-ary AND.

#### create_nary_or(fs: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigSignal](#aigverse.networks.AigSignal)]) → [AigSignal](#aigverse.networks.AigSignal)

Creates an n-ary OR.

#### create_nary_xor(fs: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigSignal](#aigverse.networks.AigSignal)]) → [AigSignal](#aigverse.networks.AigSignal)

Creates an n-ary XOR.

#### clone_node(other: [Aig](#aigverse.networks.Aig), source: [int](https://docs.python.org/3/builtins/functions.html#int), children: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigSignal](#aigverse.networks.AigSignal)]) → [AigSignal](#aigverse.networks.AigSignal)

Clones one node from `other` into this network.

#### nodes() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all nodes in order of creation.

#### gates() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all non-constant and non-PI nodes in order of creation.

#### pis() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all primary input nodes in order of creation.

#### pos() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns a list of all primary output signals in order of creation.

#### fanins(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns fanin signals of node `n`.

#### fanin_size(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the number of fanins of node `n`.

#### fanout_size(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the number of fanouts of node `n`.

#### is_constant(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a constant node.

#### is_pi(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a primary input.

#### has_and(a: [AigSignal](#aigverse.networks.AigSignal), b: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal) | [None](https://docs.python.org/3/builtins/constants.html#None)

Returns whether an AND with fanins `a` and `b` already exists.

#### is_and(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an AND node.

#### is_or(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an OR node.

#### is_xor(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an XOR node.

#### is_maj(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a majority node.

#### is_ite(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an if-then-else node.

#### is_xor3(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a 3-input XOR node.

#### is_nary_and(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an n-ary AND node.

#### is_nary_or(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is an n-ary OR node.

#### to_edge_list(regular_weight: [int](https://docs.python.org/3/builtins/functions.html#int) = 0, inverted_weight: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [AigEdgeList](#aigverse.networks.AigEdgeList)

Converts the network to an edge list.

Emits one edge per structural fanin connection, plus one edge per primary output pointing to a synthetic
target index beyond the last node. Useful for feeding the network’s structure into graph algorithms, GNN
frameworks, or other tooling that consumes edge-list-style graphs.

* **Parameters:**
  * **regular_weight** – Weight assigned to non-inverted edges.
  * **inverted_weight** – Weight assigned to inverted edges.
* **Returns:**
  The corresponding edge-list representation.

#### to_index_list() → [AigIndexList](#aigverse.networks.AigIndexList)

Converts the network to an index-list encoding.

* **Returns:**
  The corresponding index-list representation.

#### to_networkx(, levels: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, fanouts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, node_tts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, graph_tts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, dtype: [type](#aigverse.networks.AigRegister.type)[[generic](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.generic)] = ...) → [DiGraph](https://networkx.org/documentation/stable/reference/classes/digraph.html#networkx.DiGraph)

Converts an `Aig` to a [`DiGraph`](https://networkx.org/documentation/stable/reference/classes/digraph.html#networkx.DiGraph).

This function transforms the AIG into a directed graph representation
using the NetworkX library. It allows for the inclusion of various
attributes for the graph, its nodes, and edges, making it suitable
for graph-based machine learning tasks.

Note that the constant-0 node is always included in the graph, as
index 0, even if it is not referenced by any edges.

* **Parameters:**
  * **self** – The AIG object to convert.
  * **levels** – If True, computes and adds level information for each node
    and the total number of levels to the graph, as attributes
    `level` and `levels`, respectively. Defaults to False.
  * **fanouts** – If True, adds the fanout count for each node as an integer
    `fanouts` attribute (`0` for synthetic PO nodes).
    Defaults to False.
  * **node_tts** – If True, computes and adds a truth table for each node
    as a `function` attribute. Defaults to False.
  * **graph_tts** – If True, computes and adds the graph’s overall truth
    table as a `function` attribute to the graph. Defaults to False.
  * **dtype** – The data type for truth tables and all one-hot encodings.
    Defaults to [`int8`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.int8). For machine learning tasks, a
    floating-point type such as [`float32`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.float32) or
    [`float64`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.float64) may be more appropriate, as it allows
    for gradient-based optimization.
* **Returns:**
  A [`DiGraph`](https://networkx.org/documentation/stable/reference/classes/digraph.html#networkx.DiGraph) representing the AIG.

Graph Attributes:
: - type (str): `"AIG"`.
  - num_pis (int): Number of primary inputs.
  - num_pos (int): Number of primary outputs.
  - num_gates (int): Number of AND gates.
  - levels (int, optional): Total number of levels in the AIG.
  - function (list[[`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)], optional): Graph’s truth tables.
  - name (str, optional): Network name (only for `NamedAig`).

Node Attributes:
: - index (int): The node’s identifier.
  - level (int, optional): The level of the node in the AIG.
  - fanouts (int, optional): Fanout count of the node.
    : Included when `fanouts=True`.
  - function ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), optional): The node’s truth table.
  - type ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)): A one-hot encoded vector representing
    : the node type (`[const, pi, gate, po]`). The data type is determined
      by the `dtype` argument, defaulting to [`int8`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.int8).

Edge Attributes:
: - type ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)): A one-hot encoded vector representing the edge
    : type (`[regular, inverted]`). The data type is determined by the
      `dtype` argument, defaulting to [`int8`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.int8).
  - name (str, optional): Signal name or primary output name for edges to synthetic
    : PO nodes (only for `NamedAig`).

#### to_graph_tensors(node_encoding: [NodeTensorEncoding](#aigverse.networks.NodeTensorEncoding) = ..., edge_encoding: [EdgeTensorEncoding](#aigverse.networks.EdgeTensorEncoding) = ..., , levels: [bool](https://docs.python.org/3/builtins/functions.html#bool) = True, fanouts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, node_tts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False) → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)

Exports graph tensors for machine-learning workflows.

Returns sparse graph topology and features as DLPack-compatible arrays.

Edge encoding mapping:
: - `BINARY`: regular=0.0, inverted=1.0
  - `SIGNED`: regular=+1.0, inverted=-1.0
  - `ONE_HOT`: regular=[1.0, 0.0], inverted=[0.0, 1.0]

Node encoding mapping:
: - `INTEGER`: constant=0, pi=1, gate=2, po=3
  - `ONE_HOT`: [constant, pi, gate, po]

* **Parameters:**
  * **node_encoding** – Node encoding mode as [`NodeTensorEncoding`](#aigverse.networks.NodeTensorEncoding).
  * **edge_encoding** – Edge encoding mode as [`EdgeTensorEncoding`](#aigverse.networks.EdgeTensorEncoding).
  * **levels** – Appends logic level as a node feature.
  * **fanouts** – Appends fanout size as a node feature.
  * **node_tts** – Appends simulated node/output truth-table bits.
* **Returns:**
  A dictionary with `edge_index` (shape `(2, E)`, dtype `int64`),
  `edge_attr` (shape `(E, D_edge)`, dtype `float32`), and `node_attr`
  (shape `(N, D_node)`, dtype `float32`).

#### \_\_len_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the number of nodes.

#### \_\_iter_\_() → [Iterator](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns an iterator over all nodes.

#### \_\_contains_\_(value: [object](https://docs.python.org/3/builtins/functions.html#object)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether a node index is contained in the network.

#### \_\_bool_\_() → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns `True` for non-trivial networks.

#### \_\_copy_\_() → [Aig](#aigverse.networks.Aig)

Returns a shallow structural copy.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [Aig](#aigverse.networks.Aig)

Returns a deep structural copy.

#### \_\_setstate_\_(state: [object](https://docs.python.org/3/builtins/functions.html#object)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Restores a network from a pickled state tuple.

* **Parameters:**
  **state** – Tuple containing one index-list payload.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If the state shape or payload is invalid.

#### \_\_getstate_\_() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)

Returns pickle state as an index-list tuple.

Preserves only combinational structure and does not capture augmented view metadata.

### *class* NamedAig

### *class* NamedAig(ntk: [NamedAig](#aigverse.networks.NamedAig))

### *class* NamedAig(ntk: [Aig](#aigverse.networks.Aig))

Bases: [`Aig`](#aigverse.networks.Aig)

Extends a network with input/output and node names.

#### clone() → [NamedAig](#aigverse.networks.NamedAig)

Creates a structural copy including names.

#### \_\_copy_\_() → [NamedAig](#aigverse.networks.NamedAig)

Returns a shallow copy of the named view.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [NamedAig](#aigverse.networks.NamedAig)

Returns a deep copy of the named view.

#### create_pi(name: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = '') → [AigSignal](#aigverse.networks.AigSignal)

Creates a primary input with an optional name.

#### create_po(f: [AigSignal](#aigverse.networks.AigSignal), name: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = '') → [int](https://docs.python.org/3/builtins/functions.html#int)

Creates a primary output with an optional name.

#### set_network_name(name: [str](https://docs.python.org/3/builtins/stdtypes.html#str)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Sets the network name.

#### get_network_name() → [str](https://docs.python.org/3/builtins/stdtypes.html#str)

Returns the network name.

#### has_name(s: [AigSignal](#aigverse.networks.AigSignal)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether signal `s` has a name.

#### set_name(s: [AigSignal](#aigverse.networks.AigSignal), name: [str](https://docs.python.org/3/builtins/stdtypes.html#str)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Assigns a name to signal `s`.

#### get_name(s: [AigSignal](#aigverse.networks.AigSignal)) → [str](https://docs.python.org/3/builtins/stdtypes.html#str)

Returns the name of signal `s`.

#### has_output_name(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether output `index` has a name.

#### set_output_name(index: [int](https://docs.python.org/3/builtins/functions.html#int), name: [str](https://docs.python.org/3/builtins/stdtypes.html#str)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Sets the name of output `index`.

#### get_output_name(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [str](https://docs.python.org/3/builtins/stdtypes.html#str)

Returns the name of output `index`.

### *class* DepthAig

### *class* DepthAig(ntk: [DepthAig](#aigverse.networks.DepthAig))

### *class* DepthAig(ntk: [Aig](#aigverse.networks.Aig))

Bases: [`Aig`](#aigverse.networks.Aig)

Extends a network with depth information.

#### clone() → [DepthAig](#aigverse.networks.DepthAig)

Creates a copy of the depth view.

#### \_\_copy_\_() → [DepthAig](#aigverse.networks.DepthAig)

Returns a shallow copy of the depth view.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [DepthAig](#aigverse.networks.DepthAig)

Returns a deep copy of the depth view.

#### *property* num_levels *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Current network depth in levels.

#### level(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the level of node `n`.

#### is_on_critical_path(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether node `n` is on at least one critical path.

#### update_levels() → [None](https://docs.python.org/3/builtins/constants.html#None)

Recomputes level information.

#### create_po(f: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Creates an output and updates depth information.

### *class* FanoutAig

### *class* FanoutAig(ntk: [Aig](#aigverse.networks.Aig))

### *class* FanoutAig(ntk: [FanoutAig](#aigverse.networks.FanoutAig))

Bases: [`Aig`](#aigverse.networks.Aig)

Extends a network with fanout information.

#### clone() → [FanoutAig](#aigverse.networks.FanoutAig)

Creates a structural copy of the fanout view.

#### \_\_copy_\_() → [FanoutAig](#aigverse.networks.FanoutAig)

Returns a shallow copy of the fanout view.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [FanoutAig](#aigverse.networks.FanoutAig)

Returns a deep copy of the fanout view.

#### fanouts(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns fanout nodes of node `n`.

### *class* AigCut(ntk: [Aig](#aigverse.networks.Aig), leaves: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[int](https://docs.python.org/3/builtins/functions.html#int)], root: [AigSignal](#aigverse.networks.AigSignal))

### *class* AigCut(ntk: [Aig](#aigverse.networks.Aig), leaves: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigSignal](#aigverse.networks.AigSignal)], root: [AigSignal](#aigverse.networks.AigSignal))

Implements an isolated view on a single cut in a network.

This view creates a network from a single cut with a single output root
and a set of leaves. This is a standalone structural descriptor; it does
not inherit from the network type and only exposes read-only inspection
methods.

#### NOTE
This view clears all nodes’ visited flags before construction to ensure
the cut is constructed correctly. The view guarantees that all nodes in
the view will have a 0 visited flag after construction.

#### clone() → [AigCut](#aigverse.networks.AigCut)

Creates a structural copy of the cut view.

#### \_\_copy_\_() → [AigCut](#aigverse.networks.AigCut)

Returns a shallow copy of the cut view.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [AigCut](#aigverse.networks.AigCut)

Returns a deep copy of the cut view.

#### nodes() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all nodes in the cut view.

#### gates() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all gate nodes in the cut view.

#### pis() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns a list of all primary input (leaf) nodes in the cut view.

#### pos() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns a list containing the root signal of the cut view.

#### is_pi(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a primary input (leaf) in the cut view.

#### *property* size *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of nodes in the cut view.

#### *property* num_pis *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary inputs (leaves) in the cut view.

#### *property* num_pos *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary outputs (always 1 for cut view).

#### *property* num_gates *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of logic gates in the cut view.

#### node_to_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the integer index of a node.

#### index_to_node(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the node for an index.

#### to_index_list() → [AigIndexList](#aigverse.networks.AigIndexList)

Converts the cut view to an index-list encoding.

Only the cut’s restricted node set is encoded. The resulting index list
can be decoded into a standalone Aig via `AigIndexList.to_aig()`.

* **Returns:**
  The corresponding index-list representation.

### *class* AigRegister

### *class* AigRegister(register: [AigRegister](#aigverse.networks.AigRegister))

Represents metadata for one sequential register.

#### *property* control *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

Optional control signal.

#### *property* init *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Initial value of the register.

#### *property* type *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

Register type/category.

### *class* SequentialAig

Bases: [`Aig`](#aigverse.networks.Aig)

Represents a sequential network with register interfaces.

#### clone() → [SequentialAig](#aigverse.networks.SequentialAig)

Creates a structural copy of the sequential network.

#### \_\_copy_\_() → [SequentialAig](#aigverse.networks.SequentialAig)

Returns a shallow copy of the sequential network.

#### \_\_deepcopy_\_(memo: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) → [SequentialAig](#aigverse.networks.SequentialAig)

Returns a deep copy of the sequential network.

#### create_pi() → [AigSignal](#aigverse.networks.AigSignal)

Creates a primary input.

#### create_po(f: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Creates a primary output.

#### create_ro() → [AigSignal](#aigverse.networks.AigSignal)

Creates a register output node.

#### create_ri(f: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Creates a register input signal.

#### *property* is_combinational *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether the network is combinational.

#### is_ci(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a combinational input.

#### is_pi(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a primary input.

#### is_ro(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Returns whether `n` is a register output.

#### *property* num_pis *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary inputs.

#### *property* num_pos *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of primary outputs.

#### *property* num_cis *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of combinational inputs.

#### *property* num_cos *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of combinational outputs.

#### *property* num_registers *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of registers.

#### pi_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns primary input at `index`.

#### po_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigSignal](#aigverse.networks.AigSignal)

Returns primary output at `index`.

#### ci_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns combinational input at `index`.

#### co_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigSignal](#aigverse.networks.AigSignal)

Returns combinational output at `index`.

#### ro_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns register output at `index`.

#### ri_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigSignal](#aigverse.networks.AigSignal)

Returns register input at `index`.

#### set_register(index: [int](https://docs.python.org/3/builtins/functions.html#int), reg: [AigRegister](#aigverse.networks.AigRegister)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Sets metadata for register `index`.

#### register_at(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigRegister](#aigverse.networks.AigRegister)

Returns metadata for register `index`.

#### pi_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns PI index of node `n`.

#### ci_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns CI index of node `n`.

#### co_index(s: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns CO index of signal `s`.

#### ro_index(n: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns RO index of node `n`.

#### ri_index(s: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns RI index of signal `s`.

#### ro_to_ri(s: [AigSignal](#aigverse.networks.AigSignal)) → [AigSignal](#aigverse.networks.AigSignal)

Maps a register output signal to its input.

#### ri_to_ro(s: [AigSignal](#aigverse.networks.AigSignal)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Maps a register input signal to its output.

#### to_index_list() → NoReturn

Sequential networks cannot be encoded as combinational index lists.

#### to_graph_tensors(node_encoding: [NodeTensorEncoding](#aigverse.networks.NodeTensorEncoding) = ..., edge_encoding: [EdgeTensorEncoding](#aigverse.networks.EdgeTensorEncoding) = ..., , levels: [bool](https://docs.python.org/3/builtins/functions.html#bool) = True, fanouts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, node_tts: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False) → NoReturn

Sequential networks cannot be exported as combinational graph tensors.

#### \_\_getstate_\_() → NoReturn

Sequential networks are not pickleable via combinational index-list state.

#### \_\_setstate_\_(state: [object](https://docs.python.org/3/builtins/functions.html#object)) → NoReturn

Sequential networks cannot be restored from combinational index-list state.

#### to_edge_list(regular_weight: [int](https://docs.python.org/3/builtins/functions.html#int) = 0, inverted_weight: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [AigEdgeList](#aigverse.networks.AigEdgeList)

Converts the sequential network to an edge list.

In addition to the fanin and primary-output edges emitted for combinational networks, one feedback edge per
register is added, connecting a register input to its register output.

* **Parameters:**
  * **regular_weight** – Weight assigned to non-inverted edges.
  * **inverted_weight** – Weight assigned to inverted edges.
* **Returns:**
  The corresponding edge-list representation.

#### pis() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns all primary input nodes.

#### pos() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns all primary output signals.

#### cis() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns all combinational input nodes.

#### cos() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns all combinational output signals.

#### ros() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns all register output nodes.

#### ris() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigSignal](#aigverse.networks.AigSignal)]

Returns all register input signals.

#### registers() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[AigSignal](#aigverse.networks.AigSignal), [int](https://docs.python.org/3/builtins/functions.html#int)]]

Returns all register pairs as `(ri_signal, ro_node)` tuples.

### *class* AigEdge

### *class* AigEdge(source: [int](https://docs.python.org/3/builtins/functions.html#int), target: [int](https://docs.python.org/3/builtins/functions.html#int), weight: [int](https://docs.python.org/3/builtins/functions.html#int) = 0)

Represents a directed edge in a logic network graph. A weight attribute may encode inversion.

#### *property* source *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Source node identifier.

#### *property* target *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Target node identifier.

#### *property* weight *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Edge weight value.

#### \_\_eq_\_(other: [object](https://docs.python.org/3/builtins/functions.html#object)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Checks whether two edges are equal.

* **Parameters:**
  **other** – Object to compare.
* **Returns:**
  `True` if `other` is an edge with equal fields, otherwise `False`.

#### \_\_ne_\_(other: [object](https://docs.python.org/3/builtins/functions.html#object)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Checks whether two edges are not equal.

* **Parameters:**
  **other** – Object to compare.
* **Returns:**
  `True` if `other` is not equal to this edge.

### *class* AigEdgeList

### *class* AigEdgeList(ntk: [Aig](#aigverse.networks.Aig))

### *class* AigEdgeList(edges: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigEdge](#aigverse.networks.AigEdge)])

### *class* AigEdgeList(ntk: [Aig](#aigverse.networks.Aig), edges: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[AigEdge](#aigverse.networks.AigEdge)])

Represents a list of edges associated with a network.

#### *property* ntk *: [Aig](#aigverse.networks.Aig)*

Underlying network associated with this list.

#### *property* edges *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[AigEdge](#aigverse.networks.AigEdge)]*

Stored edges in insertion order.

#### append(edge: [AigEdge](#aigverse.networks.AigEdge)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Appends an edge to the list.

* **Parameters:**
  **edge** – Edge to append.

#### clear() → [None](https://docs.python.org/3/builtins/constants.html#None)

Removes all edges from the list.

#### \_\_iter_\_() → [Iterator](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[AigEdge](#aigverse.networks.AigEdge)]

Returns an iterator over stored edges.

#### \_\_len_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the number of edges.

#### \_\_getitem_\_(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [AigEdge](#aigverse.networks.AigEdge)

Returns the edge at a given position.

* **Parameters:**
  **index** – Edge index. Negative indices are supported.
* **Returns:**
  The edge at the requested position.
* **Raises:**
  [**IndexError**](https://docs.python.org/3/builtins/exceptions.html#IndexError) – If `index` is out of bounds.

#### \_\_setitem_\_(index: [int](https://docs.python.org/3/builtins/functions.html#int), edge: [AigEdge](#aigverse.networks.AigEdge)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Replaces the edge at a given position.

* **Parameters:**
  * **index** – Edge index. Negative indices are supported.
  * **edge** – Replacement edge.
* **Raises:**
  [**IndexError**](https://docs.python.org/3/builtins/exceptions.html#IndexError) – If `index` is out of bounds.

### *class* AigIndexList(num_pis: [int](https://docs.python.org/3/builtins/functions.html#int) = 0)

### *class* AigIndexList(values: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[int](https://docs.python.org/3/builtins/functions.html#int)])

Represents an index-list encoding of an AIG network.

#### raw() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns the raw integer encoding.

* **Returns:**
  A list of encoded index-list values.

#### *property* size *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of raw entries in the encoding.

#### *property* num_gates *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of encoded gates.

#### *property* num_pis *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of encoded primary inputs.

#### *property* num_pos *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of encoded primary outputs.

#### add_inputs(n: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [None](https://docs.python.org/3/builtins/constants.html#None)

Appends primary inputs to the encoding.

* **Parameters:**
  **n** – Number of inputs to append.

#### add_and(lit0: [int](https://docs.python.org/3/builtins/functions.html#int), lit1: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Appends an AND gate to the encoding.

* **Parameters:**
  * **lit0** – First fanin literal.
  * **lit1** – Second fanin literal.

#### add_xor(lit0: [int](https://docs.python.org/3/builtins/functions.html#int), lit1: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Appends an XOR gate to the encoding.

* **Parameters:**
  * **lit0** – First fanin literal.
  * **lit1** – Second fanin literal.

#### add_output(lit: [int](https://docs.python.org/3/builtins/functions.html#int)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Appends a primary output literal.

* **Parameters:**
  **lit** – Output literal.

#### clear() → [None](https://docs.python.org/3/builtins/constants.html#None)

Clears all encoded data.

#### to_aig() → [Aig](#aigverse.networks.Aig)

Decodes the index list into an AIG network.

* **Returns:**
  A decoded AIG network.

#### gates() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]]

Returns encoded gate fanins as literal pairs.

* **Returns:**
  A list of `(lit0, lit1)` tuples for each gate.

#### pos() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns encoded primary output literals.

* **Returns:**
  A list of output literals.

#### \_\_iter_\_() → [Iterator](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[int](https://docs.python.org/3/builtins/functions.html#int)]

Returns an iterator over the raw encoding values.

#### \_\_getitem_\_(index: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns one raw encoding value by index.

* **Parameters:**
  **index** – Position in the raw encoding.
* **Returns:**
  The raw value at `index`.
* **Raises:**
  [**IndexError**](https://docs.python.org/3/builtins/exceptions.html#IndexError) – If `index` is out of range.

#### \_\_setitem_\_(index: [int](https://docs.python.org/3/builtins/functions.html#int), value: [int](https://docs.python.org/3/builtins/functions.html#int)) → [None](https://docs.python.org/3/builtins/constants.html#None)

Sets one raw encoding value by index.

* **Parameters:**
  * **index** – Position in the raw encoding.
  * **value** – Replacement raw value.
* **Raises:**
  [**IndexError**](https://docs.python.org/3/builtins/exceptions.html#IndexError) – If `index` is out of range.

#### \_\_len_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)

Returns the number of raw encoding entries.
