AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.graph.AbstractEdge Class Referenceabstract

Interface to edges of a graph. More...

+ Inheritance diagram for aud.graph.AbstractEdge:
+ Collaboration diagram for aud.graph.AbstractEdge:

Public Member Functions

abstract AbstractEdge create ()
 Create new edge instance. More...
 
AbstractGraph<? extends AbstractNode,? extends AbstractEdgegraph ()
 get graph More...
 
AbstractNode source ()
 Get source node. More...
 
AbstractNode destination ()
 get destination node More...
 
boolean hasWeight ()
 determine if edge weight is defined More...
 
double getWeight ()
 set edge weight More...
 
void setWeight (double w)
 set weight More...
 
String getLabel ()
 get text description or null if there is none More...
 
GraphvizDecorator getDecorator ()
 get decoration or null
More...
 
String toString ()
 
int compareTo (AbstractEdge other)
 
boolean equals (Object other)
 
GraphvizDecorator getDecorator ()
 get decoration or null
More...
 

Detailed Description

Interface to edges of a graph.

Note that some operations require reimplementation (or throw UnsupportedOperationException.

See also
AbstractGraph

Definition at line 11 of file AbstractEdge.java.

Member Function Documentation

◆ compareTo()

int aud.graph.AbstractEdge.compareTo ( AbstractEdge  other)

Definition at line 83 of file AbstractEdge.java.

83 {
84 if (graph_!=other.graph_)
85 throw new UnsupportedOperationException();
86 int c=src_.compareTo(other.src_);
87 return c!=0 ? c : dst_.compareTo(other.dst_);
88 }
int compareTo(AbstractNode other)

Referenced by aud.graph.AbstractEdge.equals().

+ Here is the caller graph for this function:

◆ create()

abstract AbstractEdge aud.graph.AbstractEdge.create ( )
abstract

Create new edge instance.

Must initialize any attributes introduced in subclasses of AbstractEdge.

Returns
edge instance

Reimplemented in aud.example.graph.MyEdge, and aud.graph.SimpleEdge.

◆ destination()

AbstractNode aud.graph.AbstractEdge.destination ( )

get destination node

See also
source

Definition at line 39 of file AbstractEdge.java.

39{ return dst_; }

Referenced by aud.test.GraphTest.testDirectedGraph().

+ Here is the caller graph for this function:

◆ equals()

boolean aud.graph.AbstractEdge.equals ( Object  other)

Definition at line 89 of file AbstractEdge.java.

89 {
90 return compareTo((AbstractEdge) other)==0;
91 }
int compareTo(AbstractEdge other)

References aud.graph.AbstractEdge.compareTo().

+ Here is the call graph for this function:

◆ getDecorator()

GraphvizDecorator aud.graph.AbstractEdge.getDecorator ( )

get decoration or null

Implements aud.util.GraphvizDecorable.

Definition at line 71 of file AbstractEdge.java.

71 {
72 return graph_.getDecorator();
73 }

◆ getLabel()

String aud.graph.AbstractEdge.getLabel ( )

get text description or null if there is none

Reimplemented in aud.graph.SimpleEdge.

Definition at line 57 of file AbstractEdge.java.

57 {
58 if (hasWeight()) {
59 double w=getWeight();
60 if (w==Math.floor(w)) // missing proper sprintf, Java's formatting sucks!
61 return ""+((int) getWeight());
62 else
63 return ""+w;
64 }
65 else
66 return null;
67
68 //return hasWeight() ? ""+getWeight() : (String) null;
69 }
boolean hasWeight()
determine if edge weight is defined
double getWeight()
set edge weight

References aud.graph.AbstractEdge.getWeight(), and aud.graph.AbstractEdge.hasWeight().

Referenced by aud.graph.AbstractEdge.toString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWeight()

double aud.graph.AbstractEdge.getWeight ( )

set edge weight

Returns
not-a-number (NaN) if undefined (default implementation)

Reimplemented in aud.graph.SimpleEdge.

Definition at line 47 of file AbstractEdge.java.

47{ return Double.NaN; }

Referenced by aud.graph.AbstractEdge.getLabel(), and aud.graph.AbstractEdge.hasWeight().

+ Here is the caller graph for this function:

◆ graph()

AbstractGraph<? extends AbstractNode,? extends AbstractEdge > aud.graph.AbstractEdge.graph ( )

get graph

Definition at line 26 of file AbstractEdge.java.

26 {
27 return graph_;
28 }

Referenced by aud.test.GraphTest.testDirectedGraph(), and aud.test.GraphTest.testUndirectedGraph().

+ Here is the caller graph for this function:

◆ hasWeight()

boolean aud.graph.AbstractEdge.hasWeight ( )

determine if edge weight is defined

Definition at line 42 of file AbstractEdge.java.

42{ return !Double.isNaN(getWeight()); }

References aud.graph.AbstractEdge.getWeight().

Referenced by aud.graph.AbstractEdge.getLabel(), aud.example.graph.DijkstraShortestPaths.priority(), aud.example.graph.PrimMinimumSpanningTree.priority(), and aud.example.graph.IterativeDFS1.start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setWeight()

void aud.graph.AbstractEdge.setWeight ( double  w)

set weight

Exceptions
UnsupportedOperationExceptionif edges are not weighted (link hasWeight} returns false)

Reimplemented in aud.graph.SimpleEdge.

Definition at line 52 of file AbstractEdge.java.

52 {
53 throw new UnsupportedOperationException("'setWeight' undefined");
54 }

◆ source()

AbstractNode aud.graph.AbstractEdge.source ( )

Get source node.

For undirected graphs always source.index()<=destination.index().

See also
destination
AbstractNode::index

Definition at line 35 of file AbstractEdge.java.

35{ return src_; }

Referenced by aud.test.GraphTest.testDirectedGraph().

+ Here is the caller graph for this function:

◆ toString()

String aud.graph.AbstractEdge.toString ( )

Definition at line 75 of file AbstractEdge.java.

75 {
76 String text=getLabel();
77 return src_.toString()+
78 (graph_.isDirected() ? " ->" : " --")+
79 (text!=null ? "["+text+"] " : " ")+
80 dst_.toString();
81 }
String getLabel()
get text description or null if there is none

References aud.graph.AbstractEdge.getLabel().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: