graph/community: Leiden can panic based on unknowable facts
Due to a reviewer error (my fault) the Leiden implementation can panic on the basis of input state in a way that the caller can not determine prior to the call. This goes against the Gonum design. The situation can arise when a poorly structured graph is used as an input.
The current design was necessary to allow the Leiden signature agree with the Modularize function without breaking API users. On balance, I think we need to just break users here and change the common signature to func(graph.Graph, float64, rand.Source) (ReducedGraph, error), or alternatively (or in conjunction) relax the constraint and document that it may return a poorly modularised graph if it poorly structured and then just fall through, returning the state that it is at when the maximum iteration count is exceeded.
cc @hamzajer
Source: gonum/gonum