core-data-structures#
A Python library providing common data structures including graphs, trees, and lists, with built-in traversal, path-finding, and search algorithms.
Documentation Contents#
Features#
Graphs — undirected weighted graph with adjacency dictionary representation.
Breadth-first search (BFS)
Depth-first search (DFS)
Path finding (single path, all paths, shortest path)
Trees — binary tree and simple nested-dictionary tree.
Pre-order, in-order, post-order, and level-order traversal
Recursive and iterative variants
Tree depth calculation
__iter__(in-order),__len__, and__contains__supportBinaryTreeis a container over aNode-based structure (data_structures.trees.base.Node), mirroring the list implementations’ node pattern
Lists — singly and doubly linked lists sharing a common
IList/ILinkedListinterface.Value-based CRUD:
append,prepend,insert,get/__getitem__,index,pop/pop_front/pop_back,remove(single or all occurrences)reverse,extend,clear,to_list/from_list__iter__/__contains__support, plus O(1)head/endnode accessDoubleLinkedListadditionally maintains.prevlinks for backward traversal and locates positions from whichever end (head/end) is closer
Installation#
Install from PyPI using pip:
pip install core-data-structures
uv pip install core-data-structures # Or using UV...
pip install -e ".[dev]" # For development...
Setting Up Environment#
Install required libraries:
pip install --upgrade pip
pip install virtualenv
Create Python virtual environment:
virtualenv --python=python3.12 .venv
Activate the virtual environment:
source .venv/bin/activate
Install packages#
pip install .
pip install -e ".[dev]"
Check tests and coverage#
python manager.py run-tests
python manager.py run-coverage
Contributing#
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Write tests for new functionality
Ensure all tests pass:
python manager.py run-testsRun linting:
pylint data_structuresRun security checks:
bandit -r data_structuresSubmit a pull request
License#
This project is licensed under the MIT License. See the LICENSE file for details.
Links#
Support#
For questions or support, please open an issue on GitLab or contact the maintainers.