Add removaliof duplicate undirected edges
Refractor with function for each step in computation
Add function finalize
Switch to type definitions

This makes code more readable