Skip to main content

Tools for learning about algorithms and data structures

Project description

algoaid

A collection of useful tools for students taking an introductory course in algorithms and data structures.

Installation

pip install algoaid

Features

  • Time complexity analysis of functions
  • Graphs
    • Represent: [weighted] [un]directed, disjoint-set/union find
    • Easy to input a graph
    • Run basic graph algorithms (DFS, BFS, MST, Dijkstra's and more)
    • Visualise results
  • Versatile Min/Max-heap with decrease/increase key functionality

Modules

  • Time complexity: analyse
  • Graph class: Graph
  • Priority queues: MinHeap, MaxHeap

Usage: Time Complexity Analysis

Analyse time complexity of a function with a single parameter:

1. Import

from algoaid import analyse

2. Define a Function

def f(n):
    j = 1
    while j * j < n:
        j += 1

3. Analyse

analyse(f)

Example Result

Usage: Graphs

Construct various types of graphs and run a selection of popular graph algorithms:

1. Import

from algoaid import Graph

2. Declare the Graph (each line represents an edge)

edges = """
    0..2 6
    0..1 1
    0..5 2
    .
    .
    .
    2..5 4
"""

Syntax:

  • Undirected: [node1]..[node2] [weight (optional)]
  • Directed: [from]..[to] [weight (optional)]
  • Disjoint-set: [parent]..[child]

3. Construct the Graph

# construct undirected graph
g = Graph(edges, type=Graph.GraphType.GRAPH)

# construct directed graph
g = Graph(edges, type=Graph.GraphType.DI_GRAPH)

# construct disjoint set
g = Graph(edges, type=Graph.GraphType.DISJOINT_SET)

4. Display the Graph

g.display("My Graph")

5. Run Algorithms

# Run DFS from node 0
g.dfs_tree("0")

# Run BFS from node 0
g.bfs_tree("0")

# Compute MST (requires a weighted undirected graph)
g.mst_tree()

# Run Dijkstra's algorithm from node 0 (requires a weighted graph)
g.dijkstra_tree("0")

# Topological sorting (requires a directed graph)
g.topological_sort()

# Find with path compression (requires disjoint-set)
g.show_find("6")

# Union (requires disjoint-set)
g.show_union("9", "11")

Example Results

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

algoaid-1.0.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

algoaid-1.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file algoaid-1.0.2.tar.gz.

File metadata

  • Download URL: algoaid-1.0.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for algoaid-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e253c9b3c1c0b964b0e79ad36c2d584153a4364b5ea2bef88eebd0216b241196
MD5 6ee0d8f23b5cae2b4436ae368e641104
BLAKE2b-256 be2a454727a60cf0938a88542516d6dcb3e74539765ac1451bf8b213b69399a4

See more details on using hashes here.

File details

Details for the file algoaid-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: algoaid-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for algoaid-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2eaa25a826f495b4d79d170ae6dc52cb4ed0d93075037a67394c8b7c6ea11eae
MD5 36bc70a431f8b33627227d3b9f57ea12
BLAKE2b-256 2f923730a38714e0e4245b08a120105f58a9589d2396a970d0d8d160983e28f8

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