aigverse.adapters.networkx¶
AIG to NetworkX adapter.
Module Contents¶
- to_networkx(self: Aig, *, levels: bool = False, fanouts: bool = False, node_tts: bool = False, graph_tts: bool = False, dtype: type[generic] = np.int8) DiGraph[source]¶
Converts an
Aigto aDiGraph.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
levelandlevels, respectively. Defaults to False.fanouts – If True, adds the fanout count for each node as an integer
fanoutsattribute (0for synthetic PO nodes). Defaults to False.node_tts – If True, computes and adds a truth table for each node as a
functionattribute. Defaults to False.graph_tts – If True, computes and adds the graph’s overall truth table as a
functionattribute to the graph. Defaults to False.dtype – The data type for truth tables and all one-hot encodings. Defaults to
int8. For machine learning tasks, a floating-point type such asfloat32orfloat64may be more appropriate, as it allows for gradient-based optimization.
- Returns:
A
DiGraphrepresenting 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], 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, optional): The node’s truth table.
- Edge Attributes: