There should be a function (or method) that creates (or updates) a graph so that the graph has the same traits and hash as a given input graph, for example NewWithSameTraitsAs[K comparable, T any](g Graph[K, T]) (Graph[K, T], error) or Graph.TraitsFrom[K comparable, T any](source Graph[K, T]). Note that these two suggestions have the problem that they don't indicate that the hashing function is adopted as well.
There should be a function (or method) that creates (or updates) a graph so that the graph has the same traits and hash as a given input graph, for example
NewWithSameTraitsAs[K comparable, T any](g Graph[K, T]) (Graph[K, T], error)
orGraph.TraitsFrom[K comparable, T any](source Graph[K, T])
. Note that these two suggestions have the problem that they don't indicate that the hashing function is adopted as well.This call should then be replaced accordingly: https://github.com/dominikbraun/graph/blob/af07d9489ab096a0fe898b53892076c4ce800480/trees.go#L38