Skip to content

yothgewalt/single-source-shortest-paths

Repository files navigation

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:
    git clone github.com/yothgewalt/single-source-shortest-paths.git
    cd single-source-shortest-paths
  2. Run the example:
    go run main.go

Example

Below is a simple example of how to use the SSSP algorithm:

// ...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)

About

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

Topics

Resources

Stars

Watchers

Forks

Languages