[proposal] graph: evaluate what the Graph API may look like in Go 2
Created by: mewmew
Background
Given the recent generics proposal for Go 2, it would be an idea to evaluate what the Gonum Graph API may look like if it took full advantage of the proposal in its current form.
Proposal
The intention of this issue is partly to discuss how to Graph API may evolve in the future, to allow type-safe handling of user-defined node types.
But more importantly than that, the intention of this issue and evaluation is to assess whether the current generics proposal for Go 2 (using contracts) is a good fit for defining a graph API. Both in terms of capabilities, but also in terms of readability and maintainability.
If, after discussions and evaluation there does not seem to be a good fit, then I suggest we summarize the discussions and outcomes of this issue and use that as constructive feedback to further improve the proposal for generics in Go 2.
Potential impact of proposal
For Gonum Graph users, the main impact will be to get type safety when dealing with user-defined node types and avoid having to re-implement boilerplate code simply to get a graph with a specific node type.
For Go 2, the impact is potentially quite substantial, as it may help iron out edge cases in the current proposal that make it unfit for implementing Graphs (and other data structures and container formats) in terms of capability, readability and maintainability.