-
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 Pair-based edges initializer to Graph types #198
Comments
I think this would require an initializer like so: extension WeightedGraph where Node == Tendency, Weight == Int {
init <D> (_ nodes: Set<Tendency>, _ dictionaryLiteral: D) where D: DictionaryLiteral, where D.Element == (Tendency,Int)
{
...
}
} |
See You can't actually pass a real dictionary in, because tuples are not |
But if this is for syntax sugar, then you can use the Give it a try. No guarantees here. |
Oh! Totally forgot about Hashability! |
But |
You would need to do something like: extension WeightedGraph {
init (_ nodes: Set<Tendency>, _ keyValuesPairs: KeyValuePairs<Node,Weight>) {
self.init(nodes, Dictionary(keyValuePairs.lazy.map { k,v in (UnorderedPair(k.0, k.1), v) })
}
} |
Like so, so that the edge type is constructed internally...
at the moment we have to do:
The text was updated successfully, but these errors were encountered: