An open API service indexing awesome lists of open source software.

https://github.com/yothgewalt/single-source-shortest-paths

This repository implements Single Source Shortest Paths (SSSP) algorithms in Go.
https://github.com/yothgewalt/single-source-shortest-paths

algorithm go graph sssp

Last synced: 3 months ago
JSON representation

This repository implements Single Source Shortest Paths (SSSP) algorithms in Go.

Awesome Lists containing this project

README

          

# Single Source Shortest Paths (SSSP) Algorithm

This repository implements Single Source Shortest Paths (SSSP) algorithms in Go. SSSP algorithms find the shortest paths from a given source vertex to all other vertices in a weighted graph.

## Features
- Graph data structure implementation
- Priority queue for efficient shortest path computation
- SSSP algorithm (e.g., Dijkstra's algorithm)
- Example usage in `main.go`

## File Structure
- `graph.go`: Graph representation and related methods
- `priority_queue.go`: Priority queue implementation
- `single_source_shortest_paths.go`: SSSP algorithm implementation
- `data_structure.go`: Supporting data structures
- `main.go`: Entry point and example usage
- `go.mod`: Go module definition

## Usage
1. **Clone the repository:**
```zsh
git clone github.com/yothgewalt/single-source-shortest-paths.git
cd single-source-shortest-paths
```
2. **Run the example:**
```zsh
go run main.go
```

## Example
Below is a simple example of how to use the SSSP algorithm:
```go
// ...existing code...
source := 0
shortestPaths := SSSP(graph, source)
fmt.Println("Shortest paths from source:", shortestPaths)
// ...existing code...
```

## Algorithms Implemented
- Dijkstra's Algorithm (for graphs with non-negative weights)