@Override public boolean addEdge(Number edge,Pair<? extends Integer> endpoints,EdgeType edgeType){
  if (endpoints == null)   throw new IllegalArgumentException("endpoints may not be null");
  Integer v1=endpoints.getFirst();
  Integer v2=endpoints.getSecond();
  if (v1.equals(v2))   throw new IllegalArgumentException("No self-loops");
 else   return super.addEdge(edge,endpoints,edgeType);
}

@ Override public boolean addEdge ( Number edge , Pair < ? extends Integer > endpoints , EdgeType edgeType ) { if ( endpoints == null ) throw new IllegalArgumentException ( "endpoints may not be null" ) ; Integer v1 = endpoints . getFirst ( ) ; Integer v2 = endpoints . getSecond ( ) ; if ( v1 . equals ( v2 ) ) throw new IllegalArgumentException ( "No self-loops" ) ; else return super . addEdge ( edge , endpoints , edgeType ) ; }
this anonymous class works as an undirectedsparsegraph but will not accept edges that connect a vertex to itself .
