Skip to main content

A collection of Python data structures for educational purposes

Project description

PyHelper

Python implementations of fundamental data structures for learning and practical use.

What is this?

PyHelper provides clean, well-tested implementations of common data structures:

  • Lists: Linked, Double, Circular
  • Graphs: Unified Graph class + specialized types (Undirected, Directed, Weighted) with visualization & graph theory operations
  • Trees: Hierarchical tree structures with comprehensive operations and traversals
  • Skip Lists: Deterministic and Probabilistic

Prerequisites

pip install networkx matplotlib pytest

Installation

Install from local directory (for development)

pip install -e .

Install from local directory (regular installation)

pip install .

Install from GitHub

pip install git+https://github.com/Djey8/PyHelper.git

Install from PyPI

pip install pyhelper-jkluess

Quick Start

Linked List

from 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 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 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 Complex.SkipLists.probabilisticskiplist import ProbabilisticSkipList

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

Structure

PyHelper/
├── Grundlegende_Datenstrukuren/  # Basic data structures (Lists)
├── Complex/Graphs/                # Graph data structures
├── Complex/Trees/                 # Tree data structures
└── Complex/SkipLists/             # Skip list implementations

Documentation

  • Basic Lists - LinkedList, DoubleLinkedList, CircularLinkedList
  • Graphs - Graph (unified), UndirectedGraph, DirectedGraph, WeightedUndirectedGraph, WeightedDirectedGraph
    • Unified Graph class adapts to all 4 types based on initialization
    • Shortest path algorithms: BFS (unweighted) and Dijkstra (weighted)
    • Includes: Paths, cycles, connectivity, adjacency matrices/lists
    • 64% code reduction through inheritance architecture
  • Trees - Tree, TreeNode
    • Hierarchical tree structures with parent-child relationships
    • Properties: m = n - 1, connected, acyclic, unique paths
    • Traversals: preorder, postorder, level-order
    • Operations: depth, height, levels, ancestors, descendants, path finding
  • Skip Lists - SkipList, ProbabilisticSkipList

Testing

pytest tests/ -v  # 529 tests

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-0.3.0.tar.gz (59.1 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-0.3.0-py3-none-any.whl (76.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyhelper_jkluess-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5943dcf40571edb393931d246404486696ee9507ab8fae37c420d4b390de451e
MD5 55f93e0172fd2ae63810b33dd5a5a84e
BLAKE2b-256 4f100e54ea5df09ab21d07d1c9abd1657547acd6523605be19b5d8d1cc246f1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyhelper_jkluess-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc5869e88e2ef2544eedaa2dbce484c114b38f8318499d20955fb56a31c15c2
MD5 007a772befdf2034c156e91ecb29a539
BLAKE2b-256 2bc332a1e1be500bd82aba861b43509dcd09edac1d8bb81b2d3beed76a5112bc

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