networktree-py#
A Python library for managing hierarchical networks with lifecycle management. Networktree combines tree structures and network relationships to create powerful and flexible data models.
Features#
π³ Tree Structure
Hierarchical organization of objects
Parent-child relationships
Path-based navigation
Recursive operations
πΈοΈ Network Capabilities
Node-link relationships
Bidirectional connections
Network analysis
Graph operations
βοΈ Lifecycle Management
Controlled initialization
Clean resource management
State tracking
Event handling
π Advanced Features
Matrix representations
Path finding algorithms
Clustering support
Flow analysis
Installation#
Install using pip:
pip install networktree
Or directly from source:
git clone https://framagit.org/your-username/networktree-py.git
cd networktree-py
pip install -e .
Quick Start#
Basic Usage#
from networktree import Object
# Create a simple hierarchical structure
class Component(Object):
def onPreSetup(self):
print(f"Setting up {self.name}")
def onPreCleanup(self):
print(f"Cleaning up {self.name}")
# Create objects with hierarchy
root = Component(name="root")
child1 = Component(name="child1", parent=root)
child2 = Component(name="child2", parent=root)
# Initialize the structure
root.setup() # Will recursively setup all children
# Cleanup when done
root.cleanup() # Will recursively cleanup all children
Network Relationships#
from networktree import Object
# Create network nodes with relationships
class Node(Object):
def connect_to(self, target):
self.create_link(target)
# Create and connect nodes
node1 = Node(name="node1")
node2 = Node(name="node2")
node3 = Node(name="node3")
node1.connect_to(node2)
node2.connect_to(node3)
# Analyze relationships
print(node1.outputs) # Shows connections from node1
print(node2.inputs) # Shows connections to node2
Advanced Features#
from networktree.structures.advanced import MatrixNode
# Create a matrix-based analysis
class NetworkAnalyzer(MatrixNode):
def analyze_connections(self):
matrix = self.build_matrix()
return self.analyze_connectivity(matrix)
# Use for network analysis
analyzer = NetworkAnalyzer()
results = analyzer.analyze_connections()
Documentation#
Comprehensive documentation is available at networktree.readthedocs.io
Key Topics#
Use Cases#
Networktree is ideal for:
Complex data structures
Resource management systems
Plugin architectures
Process workflows
Dependency management
Configuration systems
Analysis tools
Development#
Setup Development Environment#
# Clone the repository
git clone https://framagit.org/your-username/networktree-py.git
cd networktree-py
# Install development dependencies
pip install -e .[dev]
# Run tests
pytest
# Check code style
black .
isort .
Contributing#
Fork the repository
Create a feature branch
Commit your changes
Push to the branch
Create a Merge Request
License#
This project is licensed under the MIT License - see the LICENSE file for details.
Support#
Issue Tracker: Framagit Issues
Source Code: Framagit Repository
Acknowledgments#
Inspired by various tree and network implementations
Built with modern Python practices
Developed with extensibility in mind
Citation#
If you use networktree in your research, please cite:
@software{networktree2024,
author = {Your Name},
title = {networktree-py: A Python Library for Hierarchical Networks},
year = {2024},
publisher = {Framagit},
url = {https://framagit.org/your-username/networktree-py}
}
Contact#
Maintainer: Your Name
Email: your.email@example.com