update prim's algorithm

Signed-off-by: Andrew Tselischev <andrewtselischev@gmail.com>