コード例 #1
0
ファイル: Graph.java プロジェクト: nopanic/DNA
  @Override
  public boolean equals(Object obj) {
    Log.debug("Running equality check for graphs");

    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }

    Graph other = (Graph) obj;

    if (gds == null) {
      if (other.gds != null) {
        return false;
      }
    } else if (!gds.equals(other.gds)) {
      return false;
    }
    if (timestamp != other.timestamp) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    } else if (!name.equals(other.name)) {
      return false;
    }

    Log.debug("Basics equal, going for edges and nodes");

    if (edges == null) {
      if (other.edges != null) {
        return false;
      }
    } else if (!this.edges.equals(other.edges)) {
      Log.debug("Edges not equal (type: " + edges.getClass() + ")");
      return false;
    }
    if (nodes == null) {
      if (other.nodes != null) {
        return false;
      }
    } else if (!this.nodes.equals(other.nodes)) {
      Log.debug("Nodes not equal (type: " + nodes.getClass() + ")");
      return false;
    }
    return true;
  }
コード例 #2
0
ファイル: Graph.java プロジェクト: nopanic/DNA
 public boolean containsNodes(Edge e) {
   if (e instanceof DirectedEdge) {
     return this.containsNode(((DirectedEdge) e).getSrc())
         && this.containsNode(((DirectedEdge) e).getDst());
   } else if (e instanceof UndirectedEdge) {
     return this.containsNode(((UndirectedEdge) e).getNode1())
         && this.containsNode(((UndirectedEdge) e).getNode2());
   } else {
     Log.error("containsNode() for unsupported edge type: " + e.getClass());
     return false;
   }
 }