001package org.dllearner.utilities.graph; 002 003import java.util.Objects; 004 005import org.jgrapht.graph.DefaultEdge; 006 007/** 008 * A labeled edge in the graph. 009 * 010 * @param <T> the type of the label 011 */ 012public class LabeledEdge<T> extends DefaultEdge { 013 private T label; 014 015 /** 016 * Constructs a labeled edge 017 * 018 * @param label the label of the new edge. 019 */ 020 public LabeledEdge(T label) { 021 Objects.requireNonNull(label, "label must not be null"); 022 this.label = label; 023 } 024 025 /** 026 * Gets the label associated with this edge. 027 * 028 * @return edge label 029 */ 030 public T getLabel() { 031 return label; 032 } 033 034 @Override 035 public String toString() { 036 return "(" + getSource() + " -> " + getTarget() + " : " + label + ")"; 037 } 038}