A Python tool to build, manipulate, and interoperate with flexible graph structures
Project description
Description
annnet is a lightweight, flexible, minimal-dependencies Python package for creating, manipulating, and interoperating with diverse graph data structures. It aims to be the connective tissue ("glue") between multiple graph ecosystems (NetworkX, igraph, graph-tool, etc.) while maintaining a clean and general-purpose internal representation.
๐ Description
annnet provides a unified interface for:
- Building general-purpose graphs (simple, directed, hyper, signed, etc.)
- Managing node/edge annotations
- Indexing and fast lookups
- Importing from or exporting to various tools and file formats
Its design supports complex workflows in data science, bioinformatics, and network theory โ without locking you into a specific graph backend.
โ Features
General Graph Modeling
- Simple graphs, directed graphs, multigraphs
- Hypergraphs (via edge sets or higher-order relationships)
- Signed and weighted edges
- Rich node/edge annotations
- Efficient indexing and lookups
Import Support
- CSV, JSON, and flat files
- Native import from existing objects:
networkx.Graphigraph.Graphgraph_tool.Graphcorneto.Graph
Export & Interoperability
- NetworkX (
to_networkx()) - igraph (
to_igraph()) - graph-tool (
to_graphtool()) - CORNETO
- CSV, JSON, and custom serializations
Backend-specific Integration (if installed)
If networkx is installed, you can call any NetworkX algorithm directly using dot notation:
centrality = G.nx.degree_centrality()
How it works:
- annnet converts
Gto a NetworkX object on demand, abstracting away all the non-needed attributes. - Runs the algorithm as-is.
- Returns results directly, syncing any graph changes back to the internal representation of the
gg.Graph.
This allows you to access the full power of NetworkX algorithms with zero boilerplate.
๐ ๏ธ Installation
To install annnet, you can use pip:
pip install annnet
Optional dependencies for extended functionality:
pip install annnet[networkx,igraph]
pip install annnet[graph-tool]
pip install annnet[corneto]
๐ Quick Start
import annnet as gg
# Create a new graph
G = gg.Graph(directed=True, backend="corneto")
# Add nodes and edges
G.add_node("A", type="gene")
G.add_node("B", type="protein")
G.add_edge("A", "B", sign="+", source="literature")
# Run a NetworkX algorithm (if installed)
path = G.nx.shortest_path(source="A", target="B")
# Export to JSON
G.to_json("graph.json")
๐ฆ Refined Package Structure
The package is organized to separate core functionality, I/O operations, adapters for external libraries, and algorithms. This modular design allows for easy extension and maintenance.
annnet/
โ
โโโ __init__.py # Public API surface, version, re-exports
โโโ _version.py # Single source of truth for __version__
โ
โโโ core/ # Core, always-installed logic
โ โโโ __init__.py
โ โโโ _base.py # BaseGraph class and common interfaces
โ โโโ _graph.py # Graph class and internal state manager
โ โโโ structure.py # Core data structures (nodes, edges, incidence)
โ โโโ metadata.py # Node/edge attribute store and access helpers
โ โโโ views.py # Subgraph views, shallow/deep copies
โ โโโ state.py # Graph history, change tracking, and lazy loading
โ
โโโ io/ # Loaders and writers for files
โ โโโ __init__.py
โ โโโ csv.py # CSV format (edge list, node table)
โ โโโ json.py # JSON or JSONL parsing (streamable)
โ โโโ registry.py # Entry point registration for loaders/dumpers
โ โโโ utils.py # Format detection, path helpers
โ
โโโ adapters/ # Lazy integration with external libraries
โ โโโ __init__.py
โ โโโ _base.py # AbstractAdapter, adapter interface
โ โโโ _proxy.py # Tiny forwarding proxy
โ โโโ manager.py # Adapter registry and lazy bridge logic
โ โโโ networkx.py # If available: convert, cache, sync with NetworkX
โ โโโ igraph.py # If available
โ โโโ graphtool.py # If available
โ โโโ corneto.py # If available
โ
โโโ algorithms/ # Pure-python algorithms using core only
โ โโโ __init__.py
โ โโโ traversal.py # BFS/DFS etc.
โ
โโโ utils/ # Generic helpers not tied to graph structure
โโโ validation.py
โโโ typing.py
โโโ config.py # Global options, logging, toggles
โ๏ธ Internal Design
annnet intelligently adapts its internal representation for performance and compatibility:
- Chooses between edge lists, incidence matrices, and adjacency dicts automatically
- Keeps metadata (node/edge attributes) separate from core structure
- Lazy construction of external library representations (e.g., NetworkX) only when needed
- Copy-on-write design for subgraphs and structural mutations
๐งญ Philosophy
annnet vis designed with these principles in mind:
- Simple, consistent interface for all graph types
- Interoperability-first: integrate, donโt replace
- Performance-aware, not performance-obsessed
- Extendable and modular, not monolithic
๐ License
annnet is licensed under the BSD-3 License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file annnet-0.0.1.tar.gz.
File metadata
- Download URL: annnet-0.0.1.tar.gz
- Upload date:
- Size: 234.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8ba89101b3b974c98b0381d209275ed3334011b80d803ca50cf7a2942ac61c9
|
|
| MD5 |
06a2b4d3136befdaeb45420df162dc44
|
|
| BLAKE2b-256 |
c2da6ced88688a09ca860608292abb800e8a3cb026d4d2e160d886eb365c7d51
|
File details
Details for the file annnet-0.0.1-py3-none-any.whl.
File metadata
- Download URL: annnet-0.0.1-py3-none-any.whl
- Upload date:
- Size: 124.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb8de870cbfb78c1427aefa711e3307d16f9ab2075f54e5311919fbee66f5425
|
|
| MD5 |
02428bfa9a3c98b81d753a5962740572
|
|
| BLAKE2b-256 |
20dfbfe48ed6268ff101aca50d3663623b6eea4951116d8c984546128653995a
|