Skip to main content

A collection of Python data structures for educational purposes

Project description

PyHelper

A comprehensive library of data structures designed for learning, teaching, and practical use in computer science education and software development.

What is this?

PyHelper provides production-ready, well-tested implementations of fundamental and advanced data structures, organized by complexity:

Basic Structures - Linear Data Organization

  • Linked Lists (3 types): Forward-only, bidirectional, and circular traversal patterns
    • Use when: Dynamic sizing, frequent insertions/deletions, memory efficiency

Complex Structures - Non-Linear Data Organization

  • Graphs (Unified + 4 specialized types): Network relationships and connectivity
    • Use when: Modeling relationships, pathfinding, network analysis, dependencies
  • Trees: Hierarchical parent-child structures with guaranteed properties (m = n-1)
    • Use when: File systems, org charts, decision trees, taxonomies
  • Skip Lists (2 types): Probabilistic balanced structures for fast sorted operations
    • Use when: Sorted data with O(log n) operations without tree balancing complexity

Prerequisites

pip install networkx matplotlib pytest

Installation

Install from PyPI (Recommended)

pip install pyhelper-jkluess

After installation, import as:

import pyhelper_jkluess
# or
from pyhelper_jkluess.Complex.Trees.tree import Tree

Install from GitHub

pip install git+https://github.com/Djey8/pyhelper-jkluess.git

Install from local directory (for development)

pip install -e .

Install from local directory (regular installation)

pip install .

Quick Start

Linked List

from pyhelper_jkluess.Basic.Lists.linked_list import LinkedList

ll = LinkedList()
ll.append(10)
ll.append(20)
ll.print_list()  # 10 -> 20 -> None

Graph (Unified Class - Recommended)

from pyhelper_jkluess.Complex.Graphs.graph import Graph

# Create any graph type with parameters
g = Graph(directed=False, weighted=True)
g.add_edge("A", "B", 10)
g.add_edge("A", "C", 2)
g.add_edge("C", "B", 1)

# Find shortest path (uses Dijkstra for weighted graphs)
path, distance = g.find_shortest_path("A", "B")
print(f"Path: {path}, Distance: {distance}")  # Path: ['A', 'C', 'B'], Distance: 3

# Export/import adjacency list
adj_list = g.get_adjacency_list()
g2 = Graph(directed=False, weighted=True, data=adj_list)

# Visualize
g.visualize()  # Opens matplotlib window

Tree

from pyhelper_jkluess.Complex.Trees.tree import Tree

# Create tree with root
tree = Tree("Root")

# Add children
child_a = tree.add_child(tree.root, "A")
child_b = tree.add_child(tree.root, "B")
tree.add_child(child_a, "A1")
tree.add_child(child_a, "A2")

# Print structure
tree.print_tree()

# Traversals
print(tree.traverse_preorder())    # ['Root', 'A', 'A1', 'A2', 'B']
print(tree.traverse_levelorder())  # ['Root', 'A', 'B', 'A1', 'A2']

# Statistics
stats = tree.get_statistics()
print(f"Nodes: {stats['node_count']}, Height: {stats['height']}")

Skip List

from pyhelper_jkluess.Complex.SkipLists.probabilisticskiplist import ProbabilisticSkipList

sl = ProbabilisticSkipList()
sl.add(10)
sl.add(20)
print(sl.find(10))  # 10

Learning & Demos

New to data structures? Start with the comprehensive demo files:

python demos/linked_lists_demo.py  # Start here: basic linear structures
python demos/tree_demo.py          # Hierarchical data
python demos/binary_tree_demo.py   # Binary trees and BSTs
python demos/heap_demo.py          # Priority queues and heap sort
python demos/skip_lists_demo.py    # Probabilistic balanced structures
python demos/graph_demo.py         # Network analysis and algorithms

Each demo is a complete tutorial with 5-14 examples, explanations, and real-world use cases. See demos/README.md for the full learning path.

Project Structure

pyhelper-jkluess/          # Repository root
├── demos/                # 📚 6 comprehensive tutorial files (START HERE!)
├── pyhelper_jkluess/     # Main package (import as: import pyhelper_jkluess)
│   ├── Basic/            # Linear structures: Lists (Linked, Double, Circular)
│   │   └── Lists/        # Production-ready list implementations
│   └── Complex/          # Non-linear & advanced structures
│       ├── Graphs/       # Network structures (Unified Graph + 4 types)
│       ├── Trees/        # Hierarchical structures (Tree, Node)
│       └── SkipLists/    # Probabilistic structures (2 types)
└── tests/                # 747 comprehensive tests

Documentation by Data Structure Category

Linear Structures

  • Basic Lists - LinkedList, DoubleLinkedList, CircularLinkedList
    • Forward-only, bidirectional, and circular traversal patterns
    • When to use: Dynamic arrays, LRU caches, round-robin scheduling

Non-Linear Structures

  • Graphs - Unified Graph + 4 specialized types

    • Unified Architecture: Single Graph class adapts to all 4 types (64% code reduction)
    • Graph Theory: Paths, cycles, connectivity, shortest paths (BFS/Dijkstra)
    • Representations: Adjacency matrices and lists (import/export)
    • When to use: Network modeling, dependencies, social networks, routing
  • Trees - Tree with 39 operations

    • Properties: m = n-1 edges, connected, acyclic, unique paths between nodes
    • Traversals: Preorder, inorder, postorder, level-order
    • Features: Depth/height, ancestors/descendants, adjacency matrix/list support
    • When to use: Hierarchies, file systems, decision trees, taxonomies
  • Skip Lists - Deterministic & Probabilistic

    • Performance: O(log n) operations with probabilistic balancing
    • Types: Key-value store (SkipList) and sorted set (ProbabilisticSkipList)
    • When to use: Sorted data without complex tree balancing

Testing

pytest tests/ -v  # 747 comprehensive tests

Contributing

We use automated semantic versioning with conventional commits. See:

Quick Contribution Guide

  1. Fork and clone the repository
  2. Create a feature branch from develop
  3. Use conventional commits:
    • feat: for new features (minor version bump)
    • fix: for bug fixes (patch version bump)
    • docs: for documentation
  4. Push and create PR to develop
  5. Merge to main triggers automatic release and PyPI publish

Example:

git checkout -b feature/add-hash-table develop
git commit -m "feat(structures): add hash table implementation"
git commit -m "test(structures): add hash table tests"
git push origin feature/add-hash-table

License

MIT License

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

pyhelper_jkluess-1.3.0.tar.gz (88.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhelper_jkluess-1.3.0-py3-none-any.whl (106.0 kB view details)

Uploaded Python 3

File details

Details for the file pyhelper_jkluess-1.3.0.tar.gz.

File metadata

  • Download URL: pyhelper_jkluess-1.3.0.tar.gz
  • Upload date:
  • Size: 88.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyhelper_jkluess-1.3.0.tar.gz
Algorithm Hash digest
SHA256 9c75ef68ed3e2e5f9f0b7476d012f6e6a145a047c460e38348c0429a96e91b77
MD5 b4529bef0d61ccea8957ff99b94c2fda
BLAKE2b-256 183f5ab3354f004a12f647f4a4674e570871f748a52c1ce0edbad47b5d7e929b

See more details on using hashes here.

File details

Details for the file pyhelper_jkluess-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyhelper_jkluess-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a32df2a0eea22ba2fa86afe16cd5da1bf962ffa3a41400a4b7427ffe53eef8d2
MD5 f2a45c039d4d19a713fe498a657ccc93
BLAKE2b-256 dfee7a20520734f9bd327767ea59a2c139acf107f03472a046a42526e64b7b56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page