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

Project Structure

pyhelper-jkluess/          # Repository root
├── 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/                # 564 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  # 564 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.2.0.tar.gz (92.6 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.2.0-py3-none-any.whl (111.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyhelper_jkluess-1.2.0.tar.gz
  • Upload date:
  • Size: 92.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 3d79d7150ae349bacf06e33eb0f02d71edf9d4deb0ddab7480873070800a2ed2
MD5 388532305cb239a2210f57b234767013
BLAKE2b-256 59d7441fcd4c8bc42a2fd9cd7dc194ef3448947c7adb781edeb0a1d0cf0af86a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyhelper_jkluess-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51d33ee16f9256a1af97be9963cfd3a9607d0188869880eebfd58aa4e674a669
MD5 636560d089103780c98e4747f40243da
BLAKE2b-256 1d502720b96060d0d396e524c5f2b2d6e4f53fbe8c8b1a17bbeb83ef23a7df45

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