Network Isomorphism Solver
A Rust library for determining network isomorphism using Links Theory concepts. This solver can check if two networks are structurally identical (isomorphic), find all automorphisms (symmetries), and detect subnetwork patterns.
Overview
Network isomorphism is a fundamental problem in computer science with applications across many domains:
- Drug Discovery: Comparing molecular structures to find similar compounds
- Circuit Verification: Checking if two circuit designs are functionally equivalent
- Computer Vision: Pattern matching in image recognition
- Social Network Analysis: Detecting community structures and fraud patterns
- Cryptography: Zero-knowledge proofs and graph-based cryptographic systems
This library uses Links Theory concepts where networks are represented as collections of doublet-links (ordered pairs of source and target nodes), following the L → L² formula where "a link connects links".
Features
- Isomorphism Detection: Check if two networks have identical structure
- Mapping Discovery: Find the exact node-to-node correspondence between isomorphic networks
- Automorphism Analysis: Discover all symmetries within a network
- Subnetwork Matching: Find if one network contains another as a pattern
- Links Notation (LiNo) Support: Parse networks using the standard
links-notationcrate - Weisfeiler-Lehman Algorithm: Efficient canonical labeling for pruning the search space
Installation
Add to your Cargo.toml:
[]
= "0.2.0"
Quick Start
use ;
// Create two networks using Links Notation
let benzene1 = from_notation;
let benzene2 = from_notation;
// Check if they are isomorphic
let result = check_isomorphism;
if result.is_isomorphic
Using Links Notation (LiNo)
This library integrates with the links-notation crate for parsing standard LiNo format:
use ;
// Parse LiNo doublet format: (source target)
let network1 = from_lino.unwrap;
let network2 = from_lino.unwrap;
assert!;
// Parse named links with identifiers
let named = from_lino.unwrap;
assert!;
// Parse triplet format: (source relation target)
let triplet = from_lino.unwrap;
assert!;
The from_lino method provides proper parsing using the official LiNo grammar from the link-foundation/links-notation repository.
API Reference
Core Types
DoubletLink
A link connecting two nodes (source → target).
LinkNetwork
A network represented as a collection of doublet-links.
IsomorphismResult
Result of an isomorphism check.
Functions
is_isomorphic(network1, network2) -> bool
Quick check if two networks are isomorphic.
use ;
let net1 = from_notation;
let net2 = from_notation;
assert!;
check_isomorphism(network1, network2) -> IsomorphismResult
Check isomorphism and return the node mapping if found.
use ;
let result = check_isomorphism;
if let Some = result.mapping
find_automorphisms(network) -> Vec<HashMap<LinkId, LinkId>>
Find all automorphisms (symmetries) of a network.
use ;
// Square has 8 automorphisms (rotations + reflections)
let square = from_notation;
let autos = find_automorphisms;
assert_eq!;
contains_subnetwork(haystack, needle) -> bool
Check if a network contains another as a subnetwork pattern.
use ;
let molecule = from_notation;
let ring = from_notation;
assert!;
Real-World Use Cases
Drug Discovery
Compare molecular structures to find similar compounds:
let aspirin = from_notation;
let candidate = from_notation;
if is_isomorphic
Circuit Verification
Verify that optimized circuits maintain functional equivalence:
let original = from_notation;
let optimized = from_notation;
assert!;
Social Network Analysis
Detect fraud patterns in transaction networks:
let fraud_pattern = from_notation;
if contains_subnetwork
Algorithm
The solver uses a combination of techniques:
- Quick Rejection: Compare node counts, link counts, and degree sequences
- Weisfeiler-Lehman Refinement: Compute canonical node signatures for pruning
- Backtracking Search: Systematically explore valid node mappings
- Constraint Propagation: Use degree and adjacency constraints to prune search
The Weisfeiler-Lehman algorithm iteratively refines node labels based on neighborhood structure, creating signatures that help identify potentially equivalent nodes.
Links Theory Background
This library is inspired by Links Theory, which represents all data as doublet-links following the formula L → L² (a link connects links).
Key concepts:
- Doublet-Link: An ordered pair (source, target) representing a connection
- Link Network: A collection of doublet-links forming a structure
- Links Notation (LiNo): Human-readable format for describing networks
Related Projects
This library uses and integrates with the Link Foundation ecosystem:
- links-notation - Parser for Links Notation (LiNo) format, available in Rust, JavaScript, Python, C#, Go, and Java
- link-cli - CLI tool for manipulating links with query-based operations
- links-client - Client library for doublet-links database access
- doublets-rs - Rust implementation of associative doublet storage (requires nightly Rust)
Development
Running Tests
# Run all tests
# Run with verbose output
# Run specific test module
Code Quality
# Format code
# Run lints
# Run all checks
&& &&
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
Unlicense - Public Domain
Acknowledgments
- Inspired by Links Theory by Konstantin Encyclopedist
- Uses concepts from the Weisfeiler-Lehman graph isomorphism test
- Related projects: links-notation, links-client