Source of 30.19.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0
  3: public boolean hasEdge(T begin, T end)
  4: {
  5:    boolean found = false;
  6:    VertexInterface<T> beginVertex = vertices.getValue(begin);
  7:    VertexInterface<T> endVertex = vertices.getValue(end);
  8:    if ( (beginVertex != null) && (endVertex != null) )
  9:    {
 10:       Iterator<VertexInterface<T>> neighbors = beginVertex.getNeighborIterator();
 11:       while (!found && neighbors.hasNext())
 12:       {
 13:          VertexInterface<T> nextNeighbor = neighbors.next();
 14:          if (endVertex.equals(nextNeighbor))
 15:             found = true;
 16:       } // end while
 17:    } // end if
 18:    return found;
 19: } // end hasEdge