memory leak fixed. was incorrectly accessing index. prim's algorithm now works