Why do you need a cast here? I though Edge.getSecondVertex() returns Integer?