BitDag
A fast, memory-efficient Directed Acyclic Graph (DAG) representation in Rust, optimized for lightning-fast relationship queries using dense bit matrices.
By computing the transitive closure of the graph upon construction, BitDag achieves $O(1)$ time complexity for
immediate ancestry or descendant checks. For bulk operations—such as finding common descendants or extracting leaf
nodes—it leverages rayon to perform highly parallelized bitwise operations across the matrix.
Key Features
- $O(1)$ Relationship Checks: Instant
is_ancestor_ofandis_descendant_oflookups. - Parallelized Bulk Queries: Uses
rayonto execute bitwiseAND/ORoperations across rows and columns for rapid descendant/ancestor extraction. - Profile Minimization: Easily filter out redundant ancestor terms from a profile, leaving only the most specific ( deepest) nodes.
- Format Adapters: Built-in support for parsing standard ontology formats (OBO and JSON) directly into a bit matrix.
- Flexible Serialization: Optional support for both
serdeandminiserde.
Feature Flags
This crate is highly modular. You can opt-in to specific dependencies to keep your binary size and compilation times as low as possible.
- serde — Implements standard serialization and deserialization for core structures.
- miniserde — Implements lightweight serialization for minimal binary overhead.
- obo — Enables the OBO format adapter to ingest .obo files (requires fastobo).
- json_ontology — Enables the JSON ontology adapter to ingest JSON-formatted ontologies (requires ontolius).
Quick Start
Here is a basic example of building a BitDag from a raw list of edges and querying relationships. use bitdag::edge::Edge; use bitdag::bitdag::BitDag;
Using Format Adapters
If you are working with external ontologies, you can use the built-in adapters (ensure you have the correct feature flags enabled).