Exemplo n.º 1
0
 /** @see GraphListener#edgeRemoved(GraphEdgeChangeEvent) */
 public void edgeRemoved(GraphEdgeChangeEvent<V, E> e) {
   E edge = e.getEdge();
   V source = graph.getEdgeSource(edge);
   V target = graph.getEdgeTarget(edge);
   if (successorMap.containsKey(source)) {
     successorMap.get(source).removeNeighbor(target);
   }
   if (predecessorMap.containsKey(target)) {
     predecessorMap.get(target).removeNeighbor(source);
   }
 }
Exemplo n.º 2
0
  /** @see GraphListener#edgeAdded(GraphEdgeChangeEvent) */
  public void edgeAdded(GraphEdgeChangeEvent<V, E> e) {
    E edge = e.getEdge();
    V source = graph.getEdgeSource(edge);
    V target = graph.getEdgeTarget(edge);

    // if a map does not already contain an entry,
    // then skip addNeighbor, since instantiating the map
    // will take care of processing the edge (which has already
    // been added)

    if (successorMap.containsKey(source)) {
      getSuccessors(source).addNeighbor(target);
    } else {
      getSuccessors(source);
    }
    if (predecessorMap.containsKey(target)) {
      getPredecessors(target).addNeighbor(source);
    } else {
      getPredecessors(target);
    }
  }