Skip to content

✨ Refactored Cut View on AIG#368

Open
wjrforcyber wants to merge 2 commits into
marcelwa:mainfrom
wjrforcyber:cut-refactor
Open

✨ Refactored Cut View on AIG#368
wjrforcyber wants to merge 2 commits into
marcelwa:mainfrom
wjrforcyber:cut-refactor

Conversation

@wjrforcyber

@wjrforcyber wjrforcyber commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Cut view on AIG for analysis.
Related to the old PR #315 , refactored based on the comment.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

Summary by CodeRabbit

  • New Features
    • Added an Cut class that provides an isolated, read-only view of a single cut, including inspection helpers (nodes/gates/PIs/POs), PI classification, index mapping, and cloning/copying.
    • Added to_index_list() for encoding just the cut and decoding it back into a standalone AIG.
  • Documentation
    • Expanded documentation with a new “Cut Views” section and runnable examples covering construction, iteration, and validity rules.
  • Tests
    • Added unit tests validating construction, properties, iteration, indexing, copy semantics, and cut-only encoding/decoding.

Signed-off-by: JingrenWang <wjrforcyber@163.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8433940a-bc98-4232-9df2-f2ccca4bbb3f

📥 Commits

Reviewing files that changed from the base of the PR and between b30a14e and 08ccfaf.

📒 Files selected for processing (3)
  • python/aigverse/networks.pyi
  • src/aigverse/networks/logic_networks.cpp
  • test/networks/test_cut.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/networks/test_cut.py
  • src/aigverse/networks/logic_networks.cpp
  • python/aigverse/networks.pyi

📝 Walkthrough

Walkthrough

Adds a Cut view class to aigverse as a nanobind-wrapped mockturtle::cut_view<Ntk>. The C++ binding defines two constructor overloads for node-list or signal-list leaves, clears visited flags during construction, and exposes inspection, indexing, and copy methods. A Python type stub, comprehensive unit tests covering construction variants and to_index_list encoding, and documentation are included.

Changes

Cut View Binding

Layer / File(s) Summary
C++ Cut binding and Python type stub
src/aigverse/networks/logic_networks.cpp, python/aigverse/networks.pyi
Adds mockturtle/views/cut_view.hpp and <cstddef> includes, then defines the nanobind Cut class with two __init__ overloads (node-list and signal-list leaves), visited-flag clearing, inspection methods (nodes, gates, pis, pos, is_pi), size properties, index mapping, to_index_list, and __repr__. The .pyi stub declares the identical public interface for type checkers.
Unit tests for Cut
test/networks/test_cut.py
Nine test functions covering basic count properties, signal- and node-based leaf construction, iteration method lengths, bidirectional index mapping, is_pi classification, repr output, clone/copy semantics, and to_index_list() encoding/decoding with standalone AIG reconstruction.
Cut Views documentation section
docs/aigs.md
Adds the "Cut Views" section with a runnable code example constructing small and large cuts, iterating leaves and gates, and a note on validity rules and visited-flag clearing behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

enhancement, documentation

Poem

🐇 A cut through the AIG, neat and bright,
Leaves and roots arranged just right.
Visited flags cleared with a hop,
Gates and PIs — never a flop!
The rabbit binds mockturtle's view,
And tests confirm it's working, too. 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: a refactored cut view implementation for AIG analysis with the sparkle emoji indicating a feature enhancement.
Description check ✅ Passed The description provides context linking to related work (PR #315) and a refactoring discussion, includes all required checklist items marked as complete, and adequately explains the pull request purpose.
Docstring Coverage ✅ Passed Docstring coverage is 96.43% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wjrforcyber wjrforcyber marked this pull request as draft June 17, 2026 13:19
@wjrforcyber wjrforcyber marked this pull request as ready for review June 17, 2026 21:10
@wjrforcyber wjrforcyber marked this pull request as draft June 18, 2026 05:18
Signed-off-by: JingrenWang <wjrforcyber@163.com>
@wjrforcyber wjrforcyber marked this pull request as ready for review June 18, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant