Skip to content

Commit 19433a0

Browse files
committed
Fixed Indents
1 parent 9bd6c97 commit 19433a0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Diff for: Minimum Spanning Tree/Kruskal.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ func minimumSpanningTreeKruskal<T>(graph: Graph<T>) -> (cost: Int, tree: Graph<T
1010
var cost: Int = 0
1111
var tree = Graph<T>()
1212
let sortedEdgeListByWeight = graph.edgeList.sorted(by: { $0.weight < $1.weight })
13-
13+
1414
var unionFind = UnionFind<T>()
1515
for vertex in graph.vertices {
1616
unionFind.addSetWith(vertex)
1717
}
18-
18+
1919
for edge in sortedEdgeListByWeight {
2020
let v1 = edge.vertex1
2121
let v2 = edge.vertex2
@@ -25,6 +25,6 @@ func minimumSpanningTreeKruskal<T>(graph: Graph<T>) -> (cost: Int, tree: Graph<T
2525
unionFind.unionSetsContaining(v1, and: v2)
2626
}
2727
}
28-
28+
2929
return (cost: cost, tree: tree)
3030
}

Diff for: Minimum Spanning Tree/Prim.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
func minimumSpanningTreePrim<T>(graph: Graph<T>) -> (cost: Int, tree: Graph<T>) {
1010
var cost: Int = 0
1111
var tree = Graph<T>()
12-
12+
1313
guard let start = graph.vertices.first else {
1414
return (cost: cost, tree: tree)
1515
}
16-
16+
1717
var visited = Set<T>()
1818
var priorityQueue = PriorityQueue<(vertex: T, weight: Int, parent: T?)>(
1919
sort: { $0.weight < $1.weight })
20-
20+
2121
priorityQueue.enqueue((vertex: start, weight: 0, parent: nil))
2222
while let head = priorityQueue.dequeue() {
2323
let vertex = head.vertex
2424
if visited.contains(vertex) {
2525
continue
2626
}
2727
visited.insert(vertex)
28-
28+
2929
cost += head.weight
3030
if let prev = head.parent {
3131
tree.addEdge(vertex1: prev, vertex2: vertex, weight: head.weight)
3232
}
33-
33+
3434
if let neighbours = graph.adjList[vertex] {
3535
for neighbour in neighbours {
3636
let nextVertex = neighbour.vertex
@@ -40,6 +40,6 @@ func minimumSpanningTreePrim<T>(graph: Graph<T>) -> (cost: Int, tree: Graph<T>)
4040
}
4141
}
4242
}
43-
43+
4444
return (cost: cost, tree: tree)
4545
}

0 commit comments

Comments
 (0)