41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
public class Edge implements Comparable
 | 
						|
{
 | 
						|
    private Node anfang;
 | 
						|
    private Node ende; 
 | 
						|
    private int wert; 
 | 
						|
    private boolean gerichtet; 
 | 
						|
 | 
						|
    public Edge(Node a, Node e, int w, boolean r){
 | 
						|
        this.anfang = a; 
 | 
						|
        this.ende = e;
 | 
						|
        this.wert = w ;
 | 
						|
        this.gerichtet = r;
 | 
						|
    }
 | 
						|
 | 
						|
    public Node getAnfang(){return this.anfang;}
 | 
						|
 | 
						|
    public Node getEnde(){return this.ende;}
 | 
						|
 | 
						|
    public int getWert(){return this.wert;}
 | 
						|
 | 
						|
    public boolean istGerichtet(){return this.gerichtet;}
 | 
						|
 | 
						|
    public int compareTo(Object o) {
 | 
						|
        Edge other = (Edge)o;
 | 
						|
        if(this.wert < other.wert)return -1;
 | 
						|
        if(this.wert > other.wert)return 1;
 | 
						|
        return 0;
 | 
						|
    }
 | 
						|
    
 | 
						|
    public String toString(){
 | 
						|
        /*String ergebnis = "E ";
 | 
						|
        ergebnis += anfang.getNumber() + " ";
 | 
						|
        ergebnis += ende.getNumber() + " ";
 | 
						|
        if (this.gerichtet) ergebnis += "1 ";
 | 
						|
        else ergebnis += "0 "; 
 | 
						|
        ergebnis += this.wert; 
 | 
						|
        return ergebnis; */
 | 
						|
        
 | 
						|
        return "E " + anfang.getNumber() + " " + ende.getNumber() + " " + wert + " " + (gerichtet ? 1 : 0);
 | 
						|
    }
 | 
						|
} |