fixed indexing of edges
initialise bool array in main loop to prevent set fault
added test