1 25 44 package org.jgrapht.graph; 45 46 import java.io.*; 47 48 import org.jgrapht.*; 49 50 51 57 public class ClassBasedEdgeFactory<V, E> 58 implements EdgeFactory<V, E>, Serializable 59 { 60 61 63 private static final long serialVersionUID = 3618135658586388792L; 64 65 67 private final Class <? extends E> edgeClass; 68 69 71 public ClassBasedEdgeFactory(Class <? extends E> edgeClass) 72 { 73 this.edgeClass = edgeClass; 74 } 75 76 78 81 public E createEdge(V source, V target) 82 { 83 try { 84 return edgeClass.newInstance(); 85 } catch (Exception ex) { 86 throw new RuntimeException ("Edge factory failed", ex); 87 } 88 } 89 } 90 | Popular Tags |