I found a good solution. I cluster the grid by an algorithm and iteratively cluster again those clusters which still have a total length larger than my threshold. I I got best results with the greedy_modularity_community algorithm.