Skip to content

Commit 4aba725

Browse files
committed
Add public initializers to SimpleNode, SimpleEdge and SimpleGraph
1 parent 9aa9553 commit 4aba725

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Sources/Graph/SimpleEdge.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ public struct SimpleEdge: Edge {
22
public var source: String
33
public var target: String
44
public var value: Int
5+
6+
public init(source: String, target: String, value: Int) {
7+
self.source = source
8+
self.target = target
9+
self.value = value
10+
}
511
}

Sources/Graph/SimpleGraph.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import Foundation
33
public struct SimpleGraph: Graph {
44
public var nodes: [SimpleNode]
55
public var edges: [SimpleEdge]
6+
7+
public init(nodes: [SimpleNode], edges: [SimpleEdge]) {
8+
self.nodes = nodes
9+
self.edges = edges
10+
}
611
}
712

813
extension SimpleGraph {

Sources/Graph/SimpleNode.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
public struct SimpleNode: Node {
22
public var id: String
33
public var group: Int
4+
5+
public init(id: String, group: Int) {
6+
self.id = id
7+
self.group = group
8+
}
49
}

0 commit comments

Comments
 (0)