int reltypecompare = (r1.isProperty()?1:2) - (r2.isProperty()?1:2);
if (reltypecompare != 0) return reltypecompare;
//1) TitanType
InternalType t1 = (InternalType) r1.getType(), t2 = (InternalType) r2.getType();
int typecompare = t1.compareTo(t2);
if (typecompare != 0) return typecompare;
assert t1.equals(t2);
//2) Direction
Direction dir1 = null, dir2 = null;