Skip to content

Commit 1ff1e72

Browse files
Add tests
1 parent 152baa7 commit 1ff1e72

File tree

6 files changed

+258
-11
lines changed

6 files changed

+258
-11
lines changed

Sources/SwiftGraph/UniqueElementsGraph.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// limitations under the License.
1818

1919
public typealias UnweightedUniqueElementsGraph<V: Equatable> = UniqueElementsGraph<V, UnweightedEdge>
20+
public typealias WeightedUniqueElementsGraph<V: Equatable, W: Equatable> = UniqueElementsGraph<V, WeightedEdge<W>>
2021

2122
/// A subclass of UnweightedGraph that ensures there are no pairs of equal vertices and no repeated edges.
2223
open class UniqueElementsGraph<V: Equatable, E: Edge&Equatable>: Graph {

Sources/SwiftGraph/WeightedGraph.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension Graph where E: WeightedEdgeProtocol {
5252
/// - parameter to: The ending vertex's index.
5353
/// - parameter directed: Is the edge directed? (default false)
5454
/// - parameter weight: the Weight of the edge to add.
55-
public func addEdge(fromIndex: Int, toIndex: Int, weight:W, directed: Bool = false) {
55+
public func addEdge(fromIndex: Int, toIndex: Int, weight: W, directed: Bool = false) {
5656
addEdge(E(u: fromIndex, v: toIndex, weight: weight), directed: directed)
5757
}
5858

SwiftGraph.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
7985B92A1E5A503200C100E7 /* Stack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5589B4771C0E759800D6664E /* Stack.swift */; };
3636
7985B92B1E5A503200C100E7 /* Queue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5589B47A1C0E75A700D6664E /* Queue.swift */; };
3737
B5100A4D208B97AA00C7A73A /* UnweightedGraphTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5100A4B208B97A800C7A73A /* UnweightedGraphTests.swift */; };
38+
B518BAB72232E8A40059DCB8 /* WeightedUniqueElementsGraphTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518BAB62232E8A40059DCB8 /* WeightedUniqueElementsGraphTests.swift */; };
3839
B51B460B2083E14200CD0463 /* Union.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51B460A2083E14200CD0463 /* Union.swift */; };
3940
B523F2EA2094F0E2006587ED /* UniqueElementsGraphHashableInitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B523F2E92094F0E2006587ED /* UniqueElementsGraphHashableInitTests.swift */; };
4041
B52ABD39208955BD00FBF10C /* UnionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52ABD37208955B500FBF10C /* UnionTests.swift */; };
@@ -49,8 +50,8 @@
4950
B5EF143321791348008FCC5C /* UniqueElementsGraphHashableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5EF143221791348008FCC5C /* UniqueElementsGraphHashableTests.swift */; };
5051
B5EF1437217913F1008FCC5C /* EquatableTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5EF1436217913F1008FCC5C /* EquatableTypes.swift */; };
5152
B5F07B6B222EB43000824F08 /* ArraysHaveSameElements.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F07B6A222EB43000824F08 /* ArraysHaveSameElements.swift */; };
52-
B5FE1C212231DA0C008BACAA /* UnionPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5FE1C202231DA0C008BACAA /* UnionPerformanceTests.swift */; };
5353
B5F07B6D222EB4BD00824F08 /* WeightedGraphTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F07B6C222EB4BD00824F08 /* WeightedGraphTests.swift */; };
54+
B5FE1C212231DA0C008BACAA /* UnionPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5FE1C202231DA0C008BACAA /* UnionPerformanceTests.swift */; };
5455
/* End PBXBuildFile section */
5556

5657
/* Begin PBXContainerItemProxy section */
@@ -123,6 +124,7 @@
123124
7985B91B1E5A4FCB00C100E7 /* SwiftGraphSortTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftGraphSortTests.swift; sourceTree = "<group>"; };
124125
7985B91C1E5A4FCB00C100E7 /* SwiftGraphTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftGraphTests.swift; sourceTree = "<group>"; };
125126
B5100A4B208B97A800C7A73A /* UnweightedGraphTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnweightedGraphTests.swift; sourceTree = "<group>"; };
127+
B518BAB62232E8A40059DCB8 /* WeightedUniqueElementsGraphTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeightedUniqueElementsGraphTests.swift; sourceTree = "<group>"; };
126128
B51B460A2083E14200CD0463 /* Union.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Union.swift; path = ../Sources/SwiftGraph/Union.swift; sourceTree = "<group>"; };
127129
B523F2E92094F0E2006587ED /* UniqueElementsGraphHashableInitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UniqueElementsGraphHashableInitTests.swift; sourceTree = "<group>"; };
128130
B52ABD37208955B500FBF10C /* UnionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnionTests.swift; sourceTree = "<group>"; };
@@ -137,8 +139,8 @@
137139
B5EF143221791348008FCC5C /* UniqueElementsGraphHashableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UniqueElementsGraphHashableTests.swift; sourceTree = "<group>"; };
138140
B5EF1436217913F1008FCC5C /* EquatableTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EquatableTypes.swift; sourceTree = "<group>"; };
139141
B5F07B6A222EB43000824F08 /* ArraysHaveSameElements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArraysHaveSameElements.swift; sourceTree = "<group>"; };
140-
B5FE1C202231DA0C008BACAA /* UnionPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnionPerformanceTests.swift; sourceTree = "<group>"; };
141142
B5F07B6C222EB4BD00824F08 /* WeightedGraphTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeightedGraphTests.swift; sourceTree = "<group>"; };
143+
B5FE1C202231DA0C008BACAA /* UnionPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnionPerformanceTests.swift; sourceTree = "<group>"; };
142144
/* End PBXFileReference section */
143145

144146
/* Begin PBXFrameworksBuildPhase section */
@@ -296,6 +298,7 @@
296298
children = (
297299
B5D229BD207BF36900151820 /* UniqueElementsGraphTests.swift */,
298300
B5EF143221791348008FCC5C /* UniqueElementsGraphHashableTests.swift */,
301+
B518BAB62232E8A40059DCB8 /* WeightedUniqueElementsGraphTests.swift */,
299302
B5EF143021791009008FCC5C /* UniqueElementsGraphInitTests.swift */,
300303
B523F2E92094F0E2006587ED /* UniqueElementsGraphHashableInitTests.swift */,
301304
);
@@ -547,6 +550,7 @@
547550
7985B91E1E5A4FCB00C100E7 /* SwiftGraphSearchTests.swift in Sources */,
548551
55DCCBF81F8AE2F1001913F7 /* CycleTests.swift in Sources */,
549552
B52ABD39208955BD00FBF10C /* UnionTests.swift in Sources */,
553+
B518BAB72232E8A40059DCB8 /* WeightedUniqueElementsGraphTests.swift in Sources */,
550554
55E784281ED2971E003899D0 /* MSTTests.swift in Sources */,
551555
B5100A4D208B97AA00C7A73A /* UnweightedGraphTests.swift in Sources */,
552556
B5EF1437217913F1008FCC5C /* EquatableTypes.swift in Sources */,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy