コード例 #1
0
ファイル: Graph.java プロジェクト: kewei5zhang/csv2graph
  /**
   * @param e The Edge to look up
   * @return true iff this Graph contains the Edge e
   */
  public boolean containsEdge(Edge e) {
    if (e.getOne() == null || e.getTwo() == null) {
      return false;
    }

    return this.edges.containsKey(e.hashCode());
  }
コード例 #2
0
ファイル: Graph.java プロジェクト: kewei5zhang/csv2graph
  /**
   * Accepts two vertices and a weight, and adds the edge ({one, two}, weight) iff no Edge relating
   * one and two exists in the Graph.
   *
   * @param one The first Vertex of the Edge
   * @param two The second Vertex of the Edge
   * @param weight The weight of the Edge
   * @return true iff no Edge already exists in the Graph
   */
  public boolean addEdge(Vertex one, Vertex two, double weight) {
    if (one.equals(two)) {
      return false;
    }

    // ensures the Edge is not in the Graph
    Edge e = new Edge(one, two, weight);
    if (edges.containsKey(e.hashCode())) {
      return false;
    }

    // and that the Edge isn't already incident to one of the vertices
    else if (one.containsNeighbor(e) || two.containsNeighbor(e)) {
      return false;
    }

    edges.put(e.hashCode(), e);
    one.addNeighbor(e);
    two.addNeighbor(e);
    return true;
  }
コード例 #3
0
ファイル: Graph.java プロジェクト: kewei5zhang/csv2graph
  /**
   * This method adds an existing edge, which contains vertex one, two and weight.
   *
   * @param e
   * @return true if no edge relating to one and two exists in the Graph
   */
  public boolean addEdge(Edge e) {
    if (e.getOne().equals(e.getTwo())) {
      return false;
    }

    // ensures the Edge is not in the Graph

    if (edges.containsKey(e.hashCode())) {
      return false;
    }

    // and that the Edge isn't already incident to one of the vertices
    else if (e.getOne().containsNeighbor(e) || e.getTwo().containsNeighbor(e)) {
      return false;
    }

    edges.put(e.hashCode(), e);
    e.getOne().addNeighbor(e);
    e.getTwo().addNeighbor(e);
    return true;
  }
コード例 #4
0
ファイル: MoveAction.java プロジェクト: MTU-Vitro/Vitro
 @Override
 public int hashCode() {
   return model.hashCode() ^ edge.hashCode() ^ actor.hashCode();
 }
コード例 #5
0
ファイル: Graph.java プロジェクト: kewei5zhang/csv2graph
 /**
  * This method removes the specified Edge from the Graph, including as each vertex's incidence
  * neighborhood.
  *
  * @param e The Edge to remove from the Graph
  * @return Edge The Edge removed from the Graph
  */
 public Edge removeEdge(Edge e) {
   e.getOne().removeNeighbor(e);
   e.getTwo().removeNeighbor(e);
   return this.edges.remove(e.hashCode());
 }