Prunes a complete graph (input distance matrix), keeping at least a specified number of neighbours for each node.