1. Levels
Check everything for null!
This also means not only checking if an array is null, but also if it’s subarrays are null:
matrix == null and in the for loop matrix[i] == null.
2. Energy
a)
Multigraph Bullshit
b)
Both .equals(Object other) and .hashCode() must be overriden when trying to use a HashSet or HashMap to deduplicate objects.
The hashCode must be the same for two identical objects, thus hashCode(n1, n2, energy) is not okay, when n1 and n2 should be interchangeable. We then need n1.hashCode() + n2.hashCode() + Objects.hashCode(energy).