Allow subclasses of Vertex and Edge

Don't check for class equality, but inheritance. The old equality check made inheritance impossible (e.g. for ScalaVertex). IMHO we could just drop the two lines altogether (31/32) because the compiler verifies that it's an Element.