implemented kruskal based segmentation - works like a charm ;)