12. Inspect circuit size¶
A circuit for x₁ XOR x₂ over four variables has many assignments but little stored structure. Model count measures assignments; node and pair counts measure the representation.
12.1. Inspect storage¶
Obtain totals, then inspect a snapshot to find the largest node. The snapshot owns its data and remains usable if the circuit is later transformed or freed.
size_t nodes = 0, pairs = 0;
check(tididi_size(f, &nodes, &pairs));
printf("Models: %" PRIu64 "; stored nodes: %zu; pairs: %zu\n", count(f), nodes, pairs);
TididiNodeSizes *snapshot = NULL;
check(tididi_node_sizes(f, &snapshot));
size_t largest = 0;
for (size_t i = 0; i < tididi_node_sizes_len(snapshot); ++i) {
const TididiNodeSize *row = &tididi_node_sizes_data(snapshot)[i];
if (row->pairs > largest) largest = row->pairs;
}
printf("Largest node: %zu pairs\n", largest);
tididi_node_sizes_free(snapshot);
Output:
Models: 8; stored nodes: 3; pairs: 4
Largest node: 2 pairs
12.2. Complete program¶
Download statistics.c and the
shared helper. The source includes cleanup
for all handles. Both files are included in the source checkout.