{"id":50349558,"url":"https://github.com/armandwipangestu/uninformed-search-comparison","last_synced_at":"2026-05-29T20:30:45.126Z","repository":{"id":320160327,"uuid":"1080464196","full_name":"armandwipangestu/uninformed-search-comparison","owner":"armandwipangestu","description":"A comparative analysis of BFS, DFS, and UCS — three classical uninformed search algorithms in Artificial Intelligence.","archived":false,"fork":false,"pushed_at":"2025-10-22T08:03:43.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-22T10:06:03.976Z","etag":null,"topics":["algorithm","artificial-intelligence","bfs","dfs","ucs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/armandwipangestu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-21T12:09:15.000Z","updated_at":"2025-10-22T08:04:40.000Z","dependencies_parsed_at":"2025-10-22T10:18:32.241Z","dependency_job_id":null,"html_url":"https://github.com/armandwipangestu/uninformed-search-comparison","commit_stats":null,"previous_names":["armandwipangestu/uninformed-search-comparison"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/armandwipangestu/uninformed-search-comparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armandwipangestu%2Funinformed-search-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armandwipangestu%2Funinformed-search-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armandwipangestu%2Funinformed-search-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armandwipangestu%2Funinformed-search-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/armandwipangestu","download_url":"https://codeload.github.com/armandwipangestu/uninformed-search-comparison/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armandwipangestu%2Funinformed-search-comparison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33670211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","artificial-intelligence","bfs","dfs","ucs"],"created_at":"2026-05-29T20:30:45.055Z","updated_at":"2026-05-29T20:30:45.119Z","avatar_url":"https://github.com/armandwipangestu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eUninformed Search Comparison\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![BFS](https://img.shields.io/badge/-BFS-aaabad?style=for-the-badge)\u0026nbsp;\n![DFS](https://img.shields.io/badge/-DFS-aaabad?style=for-the-badge)\u0026nbsp;\n![UCS](https://img.shields.io/badge/-UCS-aaabad?style=for-the-badge)\u0026nbsp;\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003eA comparative analysis of \u003ccode\u003eBFS\u003c/code\u003e, \u003ccode\u003eDFS\u003c/code\u003e, and \u003ccode\u003eUCS\u003c/code\u003e — three classical uninformed search algorithms in Artificial Intelligence.\u003c/p\u003e\n\n---\n\n## Table of Contents\n\n-   [Introduction](#introduction)\n    -   [Background](#background)\n    -   [Problem Statement](#problem-statement)\n-   [Theory Review](#theory-review)\n-   [Analyisis and Implemenation](#analysis-and-implementation)\n-   [Case Studies and Results](#case-studies-and-results)\n    -   [Dataset](#dataset)\n    -   [Visualization](#visualization)\n    -   [Result Analysis](#result-analysis)\n-   [Conclusion and Recommendations](#conclusions-and-recommendations)\n-   [Choose BFS or DFS or UCS?](#choose-bfs-or-dfs-or-ucs)\n-   [Real-World Application](#real-world-application)\n    -   [Breadth-First Search (BFS)](#breadth-first-search-bfs)\n        -   [Concept BFS](#concept-bfs)\n        -   [Characteristics BFS](#characteristics-bfs)\n        -   [Application BFS](#application-bfs)\n    -   [Depth-First Search (DFS)](#depth-first-search-dfs)\n        -   [Concept DFS](#concept-dfs)\n        -   [Characteristics DFS](#characteristics-dfs)\n        -   [Application DFS](#application-dfs)\n    -   [Uniformed-Cost Search (UCS)](#uniform-cost-search-ucs)\n        -   [Concept UCS](#concept-ucs)\n        -   [Characteristics UCS](#characteristic-ucs)\n        -   [Application UCS](#application-ucs)\n-   [Installation on Linux](#installation-on-linux)\n-   [Installation on Windows](#installation-on-windows)\n\n---\n\n## Introduction\n\n### Background\n\nUninformed search forms the foundation of Artificial Intelligence in solving problems without additional heuristic information. Algorithms such as **Breadth-First Search (BFS)**, **Depth-First Search (DFS)**, and **Uniform-Cost Search (UCS)** are designed to explore the _state space_ and determine a valid or optimal path to a goal.\n\n### Problem Statement\n\nHow can we compare the performance of `BFS`, `DFS`, and `UCS` based on execution time and computational complexity?\n\n---\n\n## Theory Review\n\n-   The concept of state space and how problems are represented in AI\n-   Here are the brief explanation of each algorithm:\n    -   `BFS`: level-by-level exploration (FIFO - First In First Out using Queue or Horizontal)\n    -   `DFS`: explore as deep as possible (LIFO - Last In First Out using Stack or Vertical)\n    -   `UCS`: Exploration based on minimum cumulative cost (priority queue or open and close condition)\n-   Theoritical analysis:\n    -   Completeness: whether the algorithm guarantees a solution.\n    -   Optimality: whether the found solution is the bset (minimum cost or steps).\n    -   Time and Space Complexity: how performance scales with branching factor and depth\n\n---\n\n## Analysis and Implementation\n\n-   Graph generation uses the `networkx` library with random edges and optional weights.\n-   Algorithms `BFS`, `DFS`, and `UCS` were implemented **from scratch** (no built-in pathfinding).\n-   Runtime was measured using the Python `time` module for fair performance comparison.\n\n---\n\n## Case Studies and Results\n\n-   Graph with `100`, `500`, and `1000` nodes\n\n```python\nsizes = [100, 500, 1000]\n```\n\n### Dataset\n\nExperiments were conducted on random graphs with `100`, `500`, and `1000` nodes.\n\n-   Display runtime results (tables \u0026 graph)\n\n| Nodes | BFS (s)               | DFS (s)                | UCS (s)                |\n| ----- | --------------------- | ---------------------- | ---------------------- |\n| 100   | 7.748603820800781e-05 | 3.7670135498046875e-05 | 5.9604644775390625e-05 |\n| 500   | 0.0036003589630126953 | 0.0009903907775878906  | 0.006604671478271484   |\n| 1000  | 0.030124425888061523  | 0.004039764404296875   | 0.03344416618347168    |\n\n### Visualization\n\n![Runtime Chart](results/runtime_chart.png)\n\n### Result Analysis\n\n-   `BFS` is slower as it explores all nodes at each level, but it guarantees finding the shortest path (if costs are uniform)\n-   `DFS` executes fastest because it only explores one deep path at a time, but it may miss the optimal solution.\n-   `UCS` is the slowest because it must repeatedly reorder the priority queue by cumulative path cost, ensuring the lowest-cost solution.\n\n## Conclusions and Recommendations\n\n| Algorithm | Advantages                                      | Disadvantages                                    |\n| --------- | ----------------------------------------------- | ------------------------------------------------ |\n| BFS       | Complete and finds optimal path (if equal cost) | High memory usage for large graphs               |\n| DFS       | Fast and memory-efficient                       | Not guaranteed to find the optimal solution      |\n| UCS       | Always finds the minimum-cost path.             | High computational overhead and slower execution |\n\n\u003e [!NOTE]\n\u003e While `BFS` and `UCS` require more memory, this limitation is less critical today due to larger available system resources. The key factor is still whether we prioritize speed or optimality.\n\n### Choose BFS or DFS or UCS?\n\nThe answer is depends on the situation\n\n1. Choose `BFS` if\n\n-   Always need optimal solution\n-   Doesn't have any issue on memory capacity\n\n2. Choose `DFS` if\n\n-   Not always need optimal solution\n-   Have limitation on memory capacity\n\n3. Choose `UCS` if\n\n-   Want to find the optimal solution with cost effective\n-   If have different weight on each edge or node\n\n---\n\n## Real-World Application\n\n### Breadth-First Search (BFS)\n\n#### Concept BFS\n\nBFS explores nodes level by level, ensuring that the shallowest node (or shortest path) is found first. It guarantees finding the **shortest path** when all edges have equal cost.\n\n#### Characteristics BFS\n\n-   Use **Queue (FIFO)** data structure\n-   **Complete:** will always find a solution if one exists\n-   **Optimal:** when all edge costs are equal\n\n#### Application BFS\n\n| Domain               | Example                                           | Description                                                                     |\n| -------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------- |\n| **Game Pathfinding** | NPC movement in 2D games (_Pac-Man_, _Bomberman_) | Ensures shortest route from start to goal in a grid map.                        |\n| **Puzzle Solving**   | 8-Puzzle or sliding tile games                    | Finding the minimal number of moves to reach the goal configuration.            |\n| **Social Networks**  | \"Friend of a Friend\" recommendation systems       | Finds the shortest connection path between two users in a social graph.         |\n| **AI Planning**      | Non-weighted navigation in simple environments    | Useful for path exploration in grid-based maps where all steps have equal cost. |\n\n\u003e [!NOTE]\n\u003e Analogy: BFS is like searching for a key by checking every room on the first floor before going upstairs - systematic and thorough.\n\n### Depth-First Search (DFS)\n\n#### Concept DFS\n\nDFS dives deep along one branch before backtracking to explore others. It is **fast and memory-efficient**, but may get stuck in long or infinite branches.\n\n#### Characteristics DFS\n\n-   Uses **Stack (LIFO)** data structure\n-   **Incomplete** for infinite state spaces\n-   **Not Optimal** - may find suboptimal solutions\n\n#### Application DFS\n\n| Domain                    | Example                                | Description                                                                         |\n| ------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------- |\n| **Maze Solving**          | Robot or agent solving a maze          | Explores path deeply and backtracks when hitting a dead end.                        |\n| **Game Tree Exploration** | Tic-Tac-Toe, Chess (early move search) | Explores one branch of possible moves before evaluating alternatives.               |\n| **Compiler Design**       | Abstract Syntax Tree (AST) traversal   | DFS is used to explore hierarchical program structures.                             |\n| **Web Crawling (Simple)** | Crawling websites recursively          | DFS can be used to traverse pages but needs depth limits to prevent infinite loops. |\n\n\u003e [!NOTE]\n\u003e Analogy: DFS is like walking down one hallway until it ends, then going back to try the next hallway.\n\n---\n\n### Uniform-Cost Search (UCS)\n\n#### Concept UCS\n\nUCS generalizes BFS for **weighted graphs**, where each edge has a cost. It always expands the **lowest cumulative cost** path first, ensuring the most efficient route.\n\n#### Characteristic UCS\n\n-   Uses **Priority Queue (Min-Heap)**\n-   **Complete and Optimal** (when all costs are positive)\n-   Slower but guarantees the **lowest-cost solution**\n\n#### Application UCS\n\n| Domain                     | Example                                    | Description                                                              |\n| -------------------------- | ------------------------------------------ | ------------------------------------------------------------------------ |\n| **Navigation Systems**     | Google Maps, Waze, GPS routing             | Finds the path with the shortest distance or least travel time.          |\n| **Robot Motion Planning**  | Path optimization for autonomous robots    | Choose the route with minimum energy or movement cost.                   |\n| **Logistics Optimization** | Delivery or transport cost minimization    | Finds the most cost-efficient delivery route between multiple points.    |\n| **Strategy Games**         | AI movement in terrain with variable costs | Determines best route where terrains have different travel difficulties. |\n\n\u003e [!NOTE]\n\u003e Analogy: UCS is like choosing a driving route that minimizes total fuel cost, not just distance.\n\n## Installation on Linux\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/armandwipangestu/uninformed-search-comparison\n    cd uninformed-search-comparison\n\n    sudo apt install python3-venv\n    python -m venv venv\n    source venv/bin/activate\n    ```\n\n2. Install required dependencies:\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n3. Running the script:\n\n    ```bash\n     # Run the experiment\n     python src/main.py\n\n     # Show visualize\n     python src/plot_result.py\n    ```\n\n## Installation on Windows\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/armandwipangestu/uninformed-search-comparison\n    cd uninformed-search-comparison\n\n    python -m venv venv\n    . .\\venv\\Scripts\\Activate.ps1\n    ```\n\n2. Install required dependencies:\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n3. Running the service:\n\n    ```bash\n     # Run the experiment\n     python src/main.py\n\n     # Show visualize\n     python src/plot_result.py\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmandwipangestu%2Funinformed-search-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmandwipangestu%2Funinformed-search-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmandwipangestu%2Funinformed-search-comparison/lists"}