1 22 package org.jboss.util.graph; 23 24 30 public class Edge<T> 31 { 32 private Vertex<T> from; 33 private Vertex<T> to; 34 private int cost; 35 private boolean mark; 36 37 public Edge(Vertex<T> one, Vertex<T> two) 39 { 40 from = one; 41 to = two; 42 cost = 0; 43 mark = false; 44 } 45 46 public Edge(Vertex<T> one, Vertex<T> two, int c) 48 { 49 from = one; 50 to = two; 51 cost = c; 52 mark = false; 53 } 54 55 public Vertex<T> getTo() 56 { 57 return to; 58 } 59 60 public Vertex<T> getFrom() 61 { 62 return from; 63 } 64 65 public int getCost() 66 { 67 return cost; 68 } 69 70 public void mark() 72 { 73 mark = true; 74 } 75 76 public void clearMark() 78 { 79 mark = false; 80 } 81 82 public boolean isMarked() 84 { 85 return mark; 86 } 87 88 public String toString() 89 { 90 StringBuffer tmp = new StringBuffer ("Edge[from: "); 91 tmp.append(from.getName()); 92 tmp.append(",to: "); 93 tmp.append(to.getName()); 94 tmp.append(", cost: "); 95 tmp.append(cost); 96 tmp.append("]"); 97 return tmp.toString(); 98 } 99 } 100 | Popular Tags |