Minimal interactive UI to run classical search algorithms (BFS, UCS, DFS, DLS, IDS, Bidirectional, Greedy, A*) on a graph.
python -m venv .venv
# Windows PowerShell
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
streamlit run app.py
Upload a CSV or use the bundled default_data/sample.csv
.
Select algorithm, start node, (optional) intermediate node, goal nodes, cost / heuristic columns if required, then Run.
PNG export available for current graph view.
Your CSV must at minimum describe directed edges between nodes. Each row represents a transition (edge) from a source node (NodeID
) to a neighbor (NeighborNodeID
) with associated attributes. Terminal / sink nodes can have an empty NeighborNodeID
(these rows are ignored for edge creation but still register the node).
NodeID
(int) – Unique identifier of the source node for the edge.NodeName
(string) – Human‑readable name for the node (displayed in dropdowns & hover labels).NeighborNodeID
(int or blank) – Target node ID for the directed edge. Blank/NaN means no outgoing edge for that row.
TransitionCost
(numeric) – Cost component (e.g., movement / resource use). Used if selected in cost columns.WaitingTime
(numeric) – Time delay component. Often paired withTransitionCost
.ResourceAvailability
(categorical) – Currently only displayed if you extend UI; not used in cost/heuristic automatically.SeverityLevel
(categorical) – Same as above; you can map to numbers manually by adding a numeric severity column if needed.
Any extra numeric columns you add (e.g., BedPressure
, RiskScore
, TriagePriority
) will automatically appear in:
- Cost multiselect (UCS, A*) if they are detected as numeric.
- Heuristic selector (Greedy, A*) if numeric.
Non‑numeric columns are ignored for cost/heuristic purposes but remain attached as edge attributes.
While the loader does not strictly enforce order, using this canonical order improves readability and avoids accidental header mistakes:
NodeID,NodeName,NeighborNodeID,TransitionCost,WaitingTime,ResourceAvailability,SeverityLevel
You may append additional columns after these. Do not rename required columns.
Column | Type | Notes |
---|---|---|
NodeID | int | Coerced to numeric; rows with NaN NodeID are invalid |
NodeName | str | Not coerced; keep as text |
NeighborNodeID | int/blank | Blank => ignored for edge; still registers NodeID |
TransitionCost | float/int | Optional; if missing and selected, treated as 0 |
WaitingTime | float/int | Optional; if missing and selected, treated as 0 |
(custom numeric) | float/int | Available for cost/heuristic selection |
(categorical) | str | Display only unless you add numeric transforms |
- One row = one directed edge (
NodeID
->NeighborNodeID
). - Multiple rows with same
NodeID
and differentNeighborNodeID
produce multiple outgoing edges. - Duplicate edges (same source/target) will overwrite earlier attributes (last one wins).
- Rows with missing
NeighborNodeID
help ensure the node itself appears in selectors.
- For UCS & A*: Edge cost = sum of all user‑selected cost columns.
- If you select none, fallback =
TransitionCost + WaitingTime
(if present) else 0. - BFS/DFS/DLS/IDS/Greedy treat edges as unweighted structurally (Greedy still uses a heuristic for ordering).
- Uses the selected numeric column as
h(n)
. - If node attribute missing, heuristic = average of that column across outgoing edges; if none, 0.
- If you select the same column for both cost and heuristic you will see a warning (allowed, but can reduce admissibility for A*).
- If an intermediate node is chosen (excluding Bidirectional), the system performs a two‑phase search:
- Start → Intermediate
- Intermediate → First reachable goal (from your selected set excluding the intermediate)
- Combined path is shown only if both phases succeed.
- If the intermediate is also in the goal list, Phase 2 is skipped.
- Typos in column headers (e.g.,
Node Id
) will cause a hard validation error. - Non‑numeric values in cost or heuristic columns become
NaN
then treated as 0 in aggregation. - Empty file upload or zero goals selected stops execution with an error message.
1,Node 1,4,8,2.0,High,Low
To incorporate severity or resource availability into search behavior:
- Add a numeric column (e.g.,
SeverityWeight
). - Populate it based on your mapping (e.g., Low=1, Medium=2, High=3, Critical=5).
- Select it as a cost column (for UCS/A*) or as the heuristic column (Greedy/A*).
Symptom | Possible Cause | Action |
---|---|---|
No path returned | Disconnected subgraph | Verify intermediate and goals share a reachable component |
All costs zero | No cost columns selected & no TransitionCost/WaitingTime | Select at least one numeric column |
Heuristic ignored | Algorithm not Greedy/A* | Switch to Greedy or A* |
Intermediate ignored | Using Bidirectional | Choose a different algorithm |