1. A method for clustering data comprising the steps of a. constructing a graph of a database in which each node of the graph represents a component part of the database, and every two nodes represent neighboring component parts associated by an arc representing a coupling value, b. selecting chosen component parts as blocks with unselected neighboring component parts coupled with a selected block according to coupling values, c. coarsening the graph by performing iterated weighted aggregation wherein at each iteration of the coarsening blocks are selected and coupling values updated between unselected blocks to form larger blocks to obtain hierarchical decomposition of the database and to form a pyramid structure, d. adjusting the coupling between blocks. e. detecting saliency of segments in the pyramidal structure, f. determining which component parts belong to a segment by computing recursively a degree of attachment of every component part to each of the blocks in the pyramid, and g. scanning the pyramid from coarse to fine starting at the level a segment is detected and applying relaxation sweeps to sharpen the boundaries of a segment.