gsl-331


Namegsl-331 JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryA comprehensive Python library for data structures and algorithms
upload_time2025-07-11 10:11:31
maintainerNone
docs_urlNone
authorCHICH
requires_python>=3.7
licenseNone
keywords data-structures algorithms queue stack graph priority-queue linked-list bfs dfs eece 331
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Using the Python DSA Package


## Installation
Install the package via pip:
```bash
pip install gsl_331
```

This package exposes a few classes to manage common data structures. The available classes are:
- Queue
- Stack
- Graph
- Node
- LLNode
- LinkedList
- Priority_queue

Below are usage examples for each.

## Queue
Use the Queue class to enqueue and dequeue items.
```python
from gsl_331 import Queue

q = Queue()
q.enqueue("first")
q.enqueue("second")
print("Queue front:", q.top())  # prints "first"
print("Dequeued:", q.dequeue())
print("Queue is empty:", q.is_empty())
```

## Stack
The Stack class provides LIFO operations.
```python
from gsl_331 import Stack

s = Stack()
s.push("item1")
s.push("item2")
print("Stack top:", s.top())  # prints "item2"
print("Popped item:", s.pop())
print("Is stack empty:", s.is_empty())
```

## Graph and Node
Create a graph, add vertices via random generation, and run BFS/DFS. Both the BFS and DFS operations return custom response objects. The BFS operation returns a BFS_response containing visited nodes, visit order, and parent relationships. Similarly, the DFS provides a DFS_response with entry and exit times, pending nodes, and a stack with the order of the processed nodes.
```python
from gsl_331 import Graph, Node

# Create a directed graph with labels generated for n_node vertices.
g = Graph(n=5, directed=True)
g.generate_random_graph(n_node=5)

# Choose a starting node label (e.g., "a")
bfs_response = g.BFS("a")
print(bfs_response)  # prints visited nodes, order, and parent relationships given as a whole object of type bfs response

dfs_response = g.DFS("a")
print(dfs_response)  # prints visited nodes, entry/exit times, pending nodes, and processing stack given as a whole object of type bfs response
```

## LLNode and LinkedList
Manage a linked list with LLNode and LinkedList classes.
```python
from gsl_331 import LLNode, LinkedList

# Create the head LLNode and initialize the linked list.
head = LLNode(val=10, name="10")
ll = LinkedList(head)

# Insert values
ll.insertAtHead(5)
ll.insertAtTail(15)
print("Linked List:", ll)
print("Search for 15:", ll.search(15))
ll.delete(10)
print("After deleting 10:", ll)
```

## Priority_queue
The Priority_queue supports heap operations with fast lookup by node name. Its responses include returning the top element and providing means to extract a specific node.
```python
from gsl_331 import Priority_queue

# Initialize priority queue with a list of elements.
data = [4, 2, 6, 3]
pq = Priority_queue(data)

print("Priority Queue top:", pq.top())
pq.push(1, name="unique1")
print("Priority Queue after push:", pq)
extracted = pq.exctract_node("unique1")
print("Extracted node value:", extracted.val)
```
# NOTE 
that the priority queue contains a dictionary in pq.location_tracker that gives you the real time postions of objects from your pq and makes the extraction of any node O(logn) same as all other operations

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gsl-331",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "data-structures algorithms queue stack graph priority-queue linked-list bfs dfs eece 331",
    "author": "CHICH",
    "author_email": "cbe05@mail.aub.edu",
    "download_url": "https://files.pythonhosted.org/packages/3c/12/9efe09bb7546bd90492a580f0ce276dbd61cac036da209215d815d87ea87/gsl_331-1.0.1.tar.gz",
    "platform": null,
    "description": "# Using the Python DSA Package\r\n\r\n\r\n## Installation\r\nInstall the package via pip:\r\n```bash\r\npip install gsl_331\r\n```\r\n\r\nThis package exposes a few classes to manage common data structures. The available classes are:\r\n- Queue\r\n- Stack\r\n- Graph\r\n- Node\r\n- LLNode\r\n- LinkedList\r\n- Priority_queue\r\n\r\nBelow are usage examples for each.\r\n\r\n## Queue\r\nUse the Queue class to enqueue and dequeue items.\r\n```python\r\nfrom gsl_331 import Queue\r\n\r\nq = Queue()\r\nq.enqueue(\"first\")\r\nq.enqueue(\"second\")\r\nprint(\"Queue front:\", q.top())  # prints \"first\"\r\nprint(\"Dequeued:\", q.dequeue())\r\nprint(\"Queue is empty:\", q.is_empty())\r\n```\r\n\r\n## Stack\r\nThe Stack class provides LIFO operations.\r\n```python\r\nfrom gsl_331 import Stack\r\n\r\ns = Stack()\r\ns.push(\"item1\")\r\ns.push(\"item2\")\r\nprint(\"Stack top:\", s.top())  # prints \"item2\"\r\nprint(\"Popped item:\", s.pop())\r\nprint(\"Is stack empty:\", s.is_empty())\r\n```\r\n\r\n## Graph and Node\r\nCreate a graph, add vertices via random generation, and run BFS/DFS. Both the BFS and DFS operations return custom response objects. The BFS operation returns a BFS_response containing visited nodes, visit order, and parent relationships. Similarly, the DFS provides a DFS_response with entry and exit times, pending nodes, and a stack with the order of the processed nodes.\r\n```python\r\nfrom gsl_331 import Graph, Node\r\n\r\n# Create a directed graph with labels generated for n_node vertices.\r\ng = Graph(n=5, directed=True)\r\ng.generate_random_graph(n_node=5)\r\n\r\n# Choose a starting node label (e.g., \"a\")\r\nbfs_response = g.BFS(\"a\")\r\nprint(bfs_response)  # prints visited nodes, order, and parent relationships given as a whole object of type bfs response\r\n\r\ndfs_response = g.DFS(\"a\")\r\nprint(dfs_response)  # prints visited nodes, entry/exit times, pending nodes, and processing stack given as a whole object of type bfs response\r\n```\r\n\r\n## LLNode and LinkedList\r\nManage a linked list with LLNode and LinkedList classes.\r\n```python\r\nfrom gsl_331 import LLNode, LinkedList\r\n\r\n# Create the head LLNode and initialize the linked list.\r\nhead = LLNode(val=10, name=\"10\")\r\nll = LinkedList(head)\r\n\r\n# Insert values\r\nll.insertAtHead(5)\r\nll.insertAtTail(15)\r\nprint(\"Linked List:\", ll)\r\nprint(\"Search for 15:\", ll.search(15))\r\nll.delete(10)\r\nprint(\"After deleting 10:\", ll)\r\n```\r\n\r\n## Priority_queue\r\nThe Priority_queue supports heap operations with fast lookup by node name. Its responses include returning the top element and providing means to extract a specific node.\r\n```python\r\nfrom gsl_331 import Priority_queue\r\n\r\n# Initialize priority queue with a list of elements.\r\ndata = [4, 2, 6, 3]\r\npq = Priority_queue(data)\r\n\r\nprint(\"Priority Queue top:\", pq.top())\r\npq.push(1, name=\"unique1\")\r\nprint(\"Priority Queue after push:\", pq)\r\nextracted = pq.exctract_node(\"unique1\")\r\nprint(\"Extracted node value:\", extracted.val)\r\n```\r\n# NOTE \r\nthat the priority queue contains a dictionary in pq.location_tracker that gives you the real time postions of objects from your pq and makes the extraction of any node O(logn) same as all other operations\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A comprehensive Python library for data structures and algorithms",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [
        "data-structures",
        "algorithms",
        "queue",
        "stack",
        "graph",
        "priority-queue",
        "linked-list",
        "bfs",
        "dfs",
        "eece",
        "331"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "25ffe05bb2bb8433d3642061030f2e5124266233e1b9dba160651796ad44d34b",
                "md5": "154a1d6aabeddc8146127267d9d7f0ed",
                "sha256": "b5e9b65820d0a2b990fbfd654ba9410382ea388363c0b4156f114750109c326d"
            },
            "downloads": -1,
            "filename": "gsl_331-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "154a1d6aabeddc8146127267d9d7f0ed",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7527,
            "upload_time": "2025-07-11T10:11:29",
            "upload_time_iso_8601": "2025-07-11T10:11:29.114644Z",
            "url": "https://files.pythonhosted.org/packages/25/ff/e05bb2bb8433d3642061030f2e5124266233e1b9dba160651796ad44d34b/gsl_331-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3c129efe09bb7546bd90492a580f0ce276dbd61cac036da209215d815d87ea87",
                "md5": "aa3f96c5abf3ab551d5bc395b2621589",
                "sha256": "a93f28ef5a60b8873fca439c7987dc2fe7b8ab6a2f436a94c38a3c78f017817a"
            },
            "downloads": -1,
            "filename": "gsl_331-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "aa3f96c5abf3ab551d5bc395b2621589",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7589,
            "upload_time": "2025-07-11T10:11:31",
            "upload_time_iso_8601": "2025-07-11T10:11:31.707063Z",
            "url": "https://files.pythonhosted.org/packages/3c/12/9efe09bb7546bd90492a580f0ce276dbd61cac036da209215d815d87ea87/gsl_331-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 10:11:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gsl-331"
}
        
Elapsed time: 0.41724s