Skip to content

Commit df27c68

Browse files
committed
Make graph conditionally codable
1 parent 205836d commit df27c68

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

Code/Graph/Graph.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SwiftyToolz
22

33
extension Graph: Sendable where NodeID: Sendable, NodeValue: Sendable {}
44
extension Graph: Equatable where NodeValue: Equatable {}
5+
extension Graph: Codable where NodeID: Codable, NodeValue: Codable {}
56

67
/**
78
Holds `Value`s in unique ``GraphNode``s which can be connected through ``GraphEdge``s

Code/Graph/GraphEdge.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import SwiftyToolz
33
extension GraphEdge: Sendable where NodeID: Sendable {}
44
extension GraphEdge.ID: Sendable where NodeID: Sendable {}
55

6+
extension GraphEdge: Codable where NodeID: Codable {}
7+
extension GraphEdge.ID: Codable where NodeID: Codable {}
8+
69
/**
710
Directed connection of two ``GraphNode``s in a ``Graph``
811

Code/Graph/GraphNode.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SwiftyToolz
22

33
extension GraphNode: Sendable where ID: Sendable, Value: Sendable {}
44
extension GraphNode: Equatable where Value: Equatable {}
5+
extension GraphNode: Codable where ID: Codable, Value: Codable {}
56

67
/**
78
Unique node of a ``Graph``, holds a value, can be connected to other nodes of the graph

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ SwiftNodes is already being used in production, but [Codeface](https://codeface.
221221
## Roadmap
222222

223223
1. Further align API with official Swift data structures (What would Apple do?):
224-
1. Add the usual suspects of applicable protocol conformances (`Sequence`/`Collection`, `Codable`, expressibility by literals, etc.)
224+
1. Add the usual suspects of applicable protocol conformances (`Sequence`/`Collection`, expressibility by literals, etc.)
225225
2. Compare with- and learn from API and implementation of [Swift Collections](https://github.com/apple/swift-collections)
226226
2. Round out and add algorithms (starting with the needs of Codeface):
227227
1. Make existing algorithms compatible with cyclic graphs (two of them are still not)

0 commit comments

Comments
 (0)