add triangles in graph problem