scikit-learn/scikit-learn — pull request #3952 by MechCoder (2014-12-10 15:11:44+00:00)
Title: ENH: Allow connectivity to be a callable in AgglomerativeClutering et.al

Fixes https://github.com/scikit-learn/scikit-learn/issues/3851 (It was marked easy, but I went ahead and fixed it)

The current AgglomerativeClustering conditions connectivity on the input data, which is prevents the reuse of the model for different data (if connectivity is provided initially) and definitely not in a pipeline where the input data is modified (as piinted by @jnothman ).

This fixes it by allowing it to be an int or a callable. If an int, then the kneighbors_graph is used.