Skip to content

Commit

Permalink
refactor: isolate algorithm of graph with data structures
Browse files Browse the repository at this point in the history
issue: #287
  • Loading branch information
CodeBear801 committed Apr 23, 2020
1 parent 9298dbd commit 7dfbe7b
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 1,069 deletions.
6 changes: 3 additions & 3 deletions integration/service/oasis/stationgraph/dijkstra.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package stationgraph
import "github.com/golang/glog"

// dijkstra accepts IGraph and returns all node ids in the shortest path, except start node and end node
func dijkstra(g IGraph) []nodeID {
func dijkstra(g IGraph, start, end nodeID) []nodeID {
m := newQueryHeap()

// init
m.add(g.StartNodeID(), invalidNodeID, 0, 0)
m.add(start, invalidNodeID, 0, 0)

for {
currID := m.next()
Expand All @@ -17,7 +17,7 @@ func dijkstra(g IGraph) []nodeID {
glog.Warning("PriorityQueue is empty before solution is found.")
return nil
}
if currID == g.EndNodeID() {
if currID == end {
return m.retrieve(currID)
}

Expand Down
Loading

0 comments on commit 7dfbe7b

Please sign in to comment.