Fixed HashSet access and added ToDot method for visualization