Imported from https://github.com/lnferreira/time_series_clustering_via_community_detection