graph algorithm for k tuple DS