Metadata-Version: 2.4
Name: seekerkit
Version: 1.0.1
Summary: A lightweight, modular Python library for graph traversal and state-space search algorithms.
Author: Ashwin Jain
Author-email: Ashwin Jain <ashwinjain825@gmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: requires-python

# SeekerKit

SeekerKit is a lightweight, modular Python library for graph traversal and state-space search algorithms. It provides clean, reusable implementations of common uninformed and informed search strategies, suitable for use in pathfinding, AI coursework, puzzle solving, and general graph-based problem solving.

## Features

- **Uninformed Search**
  - Breadth-First Search (`bfs`)
  - Depth-First Search (`dfs`)
  - Depth-Limited Search (`dls`)
  - Uniform-Cost Search (`ucs`)
- **Informed Search**
  - Greedy Best-First Search (`greedy_best_first_search` / `gbfs`)
  - A* Search (`a_star` / `astar`)
- Flexible graph representation: supports both dictionary-based adjacency lists and callable neighbor functions
- Support for weighted edges via `(neighbor, cost)` tuples
- Uniform `SearchResult` object returned by every algorithm, exposing the path, cost, and number of nodes visited

## Installation

Install directly from PyPI

```bash
pip install seekerkit
```

SeekerKit requires Python 3.7 or later and has no external dependencies.

## Usage

```python
from seekerkit.uninformed import bfs, dfs, ucs, dls
from seekerkit.informed import a_star, greedy_best_first_search

graph = {
    "A": ["B", "C"],
    "B": ["D"],
    "C": ["D"],
    "D": []
}

result = bfs(graph, start="A", target="D")

print(result.is_present)     # True
print(result.path)           # ['A', 'B', 'D']
print(result.cost)           # 2
print(result.nodes_visited)  # Number of nodes explored
```

### Weighted Graphs

Edges can be specified as `(neighbor, cost)` tuples to enable weighted search algorithms such as `ucs` and `a_star`:

```python
graph = {
    "A": [("B", 4), ("C", 1)],
    "B": [("D", 1)],
    "C": [("D", 5)],
    "D": []
}

result = ucs(graph, start="A", target="D")
```

### Custom Neighbor Functions

For graphs that are too large or dynamic to represent as a dictionary, pass a callable via `get_neighbors` or directly as the `graph` argument:

```python
def get_neighbors(node):
    # custom logic, e.g. querying a database or generating states
    ...

result = dfs(graph=None, start=start_state, target=goal_state, get_neighbors=get_neighbors)
```

### Informed Search

Informed algorithms additionally require a `heuristic(node, target)` function returning a numeric estimate of the distance to the target:

```python
def heuristic(node, target):
    return abs(node - target)

result = a_star(graph, start=0, target=10, heuristic=heuristic)
```

## SearchResult

Every search function returns a `SearchResult` object with the following attributes:

| Attribute       | Description                                              |
|-----------------|------------------------------------------------------------|
| `found`         | `True` if the target was reached, otherwise `False`        |
| `path`          | List of nodes from start to target (empty if not found)    |
| `cost`          | Total accumulated cost of the path                          |
| `nodes_visited` | Number of nodes explored during the search                  |
| `is_present`    | Alias property for `found`                                  |
| `depth`         | Depth of the found path (`None` if not found)                |

## License

This project is distributed under the terms specified by the author. See the `LICENSE` file for details.

## Author

Ashwin Jain — ashwinjain825@gmail.com
