Skip to content

Commit dd3ba8d

Browse files
committed
add project for SSSP with Bellman-Ford implementation
1 parent 495303b commit dd3ba8d

File tree

15 files changed

+1059
-4
lines changed

15 files changed

+1059
-4
lines changed

.travis.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ osx_image: xcode7.3
33

44
script:
55

6+
- xcodebuild test -project ./All-Pairs\ Shortest\ Paths/APSP/APSP.xcodeproj -scheme APSPTests
67
- xcodebuild test -project ./Array2D/Tests/Tests.xcodeproj -scheme Tests
78
- xcodebuild test -project ./AVL\ Tree/Tests/Tests.xcodeproj -scheme Tests
89
- xcodebuild test -project ./Binary\ Search/Tests/Tests.xcodeproj -scheme Tests
910
- xcodebuild test -project ./Binary\ Search\ Tree/Solution\ 1/Tests/Tests.xcodeproj -scheme Tests
1011
- xcodebuild test -project ./Bloom\ Filter/Tests/Tests.xcodeproj -scheme Tests
1112
- xcodebuild test -project ./Breadth-First\ Search/Tests/Tests.xcodeproj -scheme Tests
13+
- xcodebuild test -project ./Bucket\ Sort/Tests/Tests.xcodeproj -scheme Tests
1214
- xcodebuild test -project ./Heap/Tests/Tests.xcodeproj -scheme Tests
1315
- xcodebuild test -project ./Heap\ Sort/Tests/Tests.xcodeproj -scheme Tests
1416
- xcodebuild test -project ./Insertion\ Sort/Tests/Tests.xcodeproj -scheme Tests
1517
- xcodebuild test -project ./K-Means/Tests/Tests.xcodeproj -scheme Tests
1618
- xcodebuild test -project ./Linked\ List/Tests/Tests.xcodeproj -scheme Tests
19+
- xcodebuild test -project ./Longest\ Common\ Subsequence/Tests/Tests.xcodeproj -scheme Tests
1720
- xcodebuild test -project ./Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests
1821
- xcodebuild test -project ./Queue/Tests/Tests.xcodeproj -scheme Tests
1922
- xcodebuild test -project ./Quicksort/Tests/Tests.xcodeproj -scheme Tests
2023
- xcodebuild test -project ./Run-Length\ Encoding/Tests/Tests.xcodeproj -scheme Tests
2124
- xcodebuild test -project ./Select\ Minimum\ Maximum/Tests/Tests.xcodeproj -scheme Tests
2225
- xcodebuild test -project ./Selection\ Sort/Tests/Tests.xcodeproj -scheme Tests
2326
- xcodebuild test -project ./Shell\ Sort/Tests/Tests.xcodeproj -scheme Tests
24-
- xcodebuild test -project ./Stack/Tests/Tests.xcodeproj -scheme Tests
25-
- xcodebuild test -project ./Longest\ Common\ Subsequence/Tests/Tests.xcodeproj -scheme Tests
26-
- xcodebuild test -project ./Bucket\ Sort/Tests/Tests.xcodeproj -scheme Tests
27-
- xcodebuild test -project ./All-Pairs\ Shortest\ Paths/APSP/APSP.xcodeproj -scheme APSPTests
27+
- xcodebuild test -project ./Single-Source\ Shortest\ Paths\ \(Weighted\)/SSSP.xcodeproj -scheme SSSPTests
28+
- xcodebuild test -project ./Stack/Tests/Tests.xcodeproj -scheme Tests
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Graph
2+
import SSSP
3+
4+
let graph = AdjacencyMatrixGraph<String>()
5+
let s = graph.createVertex("s")
6+
let t = graph.createVertex("t")
7+
let x = graph.createVertex("x")
8+
let y = graph.createVertex("y")
9+
let z = graph.createVertex("z")
10+
11+
graph.addDirectedEdge(s, to: t, withWeight: 6)
12+
graph.addDirectedEdge(s, to: y, withWeight: 7)
13+
14+
graph.addDirectedEdge(t, to: x, withWeight: 5)
15+
graph.addDirectedEdge(t, to: y, withWeight: 8)
16+
graph.addDirectedEdge(t, to: z, withWeight: -4)
17+
18+
graph.addDirectedEdge(x, to: t, withWeight: -2)
19+
20+
graph.addDirectedEdge(y, to: x, withWeight: -3)
21+
graph.addDirectedEdge(y, to: z, withWeight: 9)
22+
23+
graph.addDirectedEdge(z, to: s, withWeight: 2)
24+
graph.addDirectedEdge(z, to: x, withWeight: 7)
25+
26+
let result = BellmanFord<String>.apply(graph, source: s)!
27+
28+
let path = result.path(z, inGraph: graph)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='osx'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

Single-Source Shortest Paths (Weighted)/SSSP.playground/playground.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)