Beispiel #1
0
 public boolean removeEdge(Vertex<T> from, Vertex<T> to) {
   Edge<T> e = from.findEdge(to);
   if (e == null) return false;
   else {
     from.remove(e);
     return true;
   }
 }
Beispiel #2
0
 public boolean addEdge(Vertex<T> from, Vertex<T> to, int cost) throws IllegalArgumentException {
   if (!verticesHash.containsKey(from.getName()))
     throw new IllegalArgumentException("from is not in graph");
   if (!verticesHash.containsKey(to.getName()))
     throw new IllegalArgumentException("to is not in graph");
   Edge<T> e = new Edge<T>(from, to, cost);
   if (from.findEdge(to) != null) return false;
   else {
     from.addEdge(e);
     return true;
   }
 }