+ T t;
+ E prev;
+ E next;
+ E pair;
+
+ private void syncm() {
+ this.prev.next = this;
+ this.next.prev = this;
+ this.pair.pair = this;
+ if (this.next.p1 != p2) throw new Error();
+ if (this.prev.p2 != p1) throw new Error();
+ }
+ private void sync() {
+ syncm();
+ this.p1.e = this;
+ System.out.println("make " + this);
+ /*
+ if (next != this && next.next != this && next.next.next == this)
+ newT();
+ */
+ }
+
+ public T newT() {
+ if (t==null) t = new T(this);
+ return t;
+ }
+
+ public void makeAdjacent(E e) {
+ if (this.next == e) return;
+ if (p2 != e.p1) throw new Error("cannot make adjacent -- no shared vertex");
+ if (t != null || e.t != null) throw new Error("cannot make adjacent -- edges not both free");
+
+ System.out.println(this + ".makeAdjacent("+e+") -- from " + this.next);
+ E freeIncident = p2.getFreeIncident();
+ if (freeIncident==null) throw new Error("unable to find freeIncident");
+
+ e.prev.next = freeIncident.next;
+ freeIncident.next.prev = e.prev;
+
+ freeIncident.next = this.next;
+ this.next.prev = freeIncident;
+
+ this.next = e;
+ e.prev = this;
+
+ syncm();
+ freeIncident.syncm();
+
+ //throw new Error("makeAdjacent() failed");
+ }
+
+ /** creates an isolated edge out in the middle of space */