-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add data carrying graph types #190
Conversation
Add TODO to add error raising
…NonCarrier information
@jsbean, this will be really handy to pull in while I am working on the PitchSpeller! Basically just felt I needed this... needs tests but they should be easy to pull over from |
/// Inserts the given `node` without making any connections to other nodes contained herein. | ||
@inlinable | ||
public mutating func insert(_ node: Node) { | ||
nodes.insert(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent this guy.
This is looking very compelling. To clarify, is the main affordance of these structures to be able to store non- Given the following values: let value: Int // (Hashable)
let data: String // (Hashable) How are these two structures different? let dg = DataGraph<Int,String>() and struct DataNode {
let value: Int
let data: String
}
extension DataNode: Equatable { }
extension DataNode: Hashable { }
let g = Graph<DataNode>() |
The two use cases given:
could potentially be implemented with the current I could be missing something crucial here, though. Lemme know, @bwetherfield ! |
I'm going to go back to |
Is NotationModel PR #123 a bit that would benefit from this? |
Yes, and further NotationalModel PR #126... So, in that PR, I've switched things from being Array-oriented to more Dictionary-oriented when it comes to
I haven't checked whether instead of passing around structures of the form struct Pitch {
let index: Index
let value: Pitch
} Judging from the fact that I could leave Let me know your reflections, @jsbean! |
This PR implements a
Node
-analog to weighted graph implementations, namely graphs where each node is assigned a piece of data. A system of protocols and structs mirror those of the ordinary graphs but with this added data carrying feature.The PR is motivated by various use cases in the
PitchSpeller
modules, where we wantPitch
valuesTendency
valueIn the above cases and in other usage, the data carrying graph types will give us O(1) lookups of data associated with the nodes thanks to the dictionary storage of the data.