package com.github.vangj.jbayes.inf.exact.graph.pptc;

public class Edge {
  protected Clique left;
  protected Clique right;

  public Edge(Clique left, Clique right) {
    this.left = left;
    this.right = right;
  }

  @Override
  public String toString() {
    return (new StringBuilder())
        .append(smaller().id())
        .append(" -- ")
        .append(bigger().id())
        .toString();
  }

  @Override
  public int hashCode() {
    return toString().hashCode();
  }

  @Override
  public boolean equals(Object object) {
    if(null == object || !(object instanceof Clique)) {
      return false;
    }
    Clique that = (Clique)object;
    return this.hashCode() == that.hashCode();
  }

  public Clique left() {
    return left;
  }

  public Clique right() {
    return right;
  }

  private Clique smaller() {
    if(left.id().compareTo(right.id()) <= 0) {
      return left;
    }
    return right;
  }

  private Clique bigger() {
    if(left.id().compareTo(right.id()) > 0) {
      return left;
    }
    return right;
  }
}

@@ -576,21 +576,19 @@
 tanceof 
-Cliqu
+Edg
 e)) %7B%0A  
@@ -615,21 +615,19 @@
   %7D%0A    
-Cliqu
+Edg
 e that =
@@ -628,21 +628,19 @@
 that = (
-Cliqu
+Edg
 e)object

fix bug; need edge instance not clique