---
title: "Discussion on \"Shortest Path in Undirected Graph\" | Hashnode"
description: "Discussion on \"Shortest Path in Undirected Graph\". Problem\nYou are given an adjacency list, adj of Undirected Graph having unit weight of the edges, find the shortest path from src to all the vertex and if it is unreachable to reach any vertex, then return -1 for that vertex.\nExamples :\nInput: adj[][..."
url: "https://hashnode.com/posts/shortest-path-in-undirected-graph/68bd818b4b9eca470640e4bc"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Shortest Path in Undirected Graph](https://chetan77.hashnode.dev/shortest-path-in-undirected-graph?utm_source=hashnode&utm_medium=feed)

Problem You are given an adjacency list, adj of Undirected Graph having unit weight of the edges, find the shortest path from src to all the vertex and if it is unreachable to reach any vertex, then return -1 for that vertex. Examples : Input: adj\[\]\[...

Sep 7, 2025 · 4 min read · chetan77.hashnode.dev  
Updated Sep 14, 2025  
Read the article

-   [#shortest-path-in-undirected-graph-with-unit-weights](https://hashnode.com/tag/shortest-path-in-undirected-graph-with-unit-weights)
-   [#undirected-graph](https://hashnode.com/tag/undirected-graph)
-   [#graphs](https://hashnode.com/tag/graphs)
-   [#dsa](https://hashnode.com/tag/dsa)
-   [#bfs](https://hashnode.com/tag/bfs)
-   [#dfs](https://hashnode.com/tag/dfs)
-   [#shortest-distance](https://hashnode.com/tag/shortest-distance)

## Written by

[Chetan Datta](https://hashnode.com/@chetan77)

@chetan77 · Hyderabad, India

  
[View profile](https://hashnode.com/@chetan77)

Software Engineer

I share my learnings here. Thanks for reading.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
