Package graphlib.edges
Class UndirectedEdge<T>
java.lang.Object
graphlib.edges.Edge<T>
graphlib.edges.UndirectedEdge<T>
Represents an undirected edge. This type of edges can be added to a undirected graph.
 Edges {a,b} and {b,a} are equal.
- 
Constructor Summary
ConstructorsConstructorDescriptionUndirectedEdge(Node<T> node1, Node<T> node2) Create an unweighted undirected edge between two nodes.UndirectedEdge(Node<T> node1, Node<T> node2, double weight) Create an undirected edge between two nodes with given weight. - 
Method Summary
 
- 
Constructor Details
- 
UndirectedEdge
Create an undirected edge between two nodes with given weight. The order in which the nodes are specified is arbitrary.- Parameters:
 node1- first nodenode2- second nodeweight- associated weight
 - 
UndirectedEdge
Create an unweighted undirected edge between two nodes. The order in which the nodes are specified is arbitrary. CallingEdge.getWeight()on this edge will returnnull. A weight may be assigned later usingEdge.setWeight(double).- Parameters:
 node1- first nodenode2- second node
 
 - 
 - 
Method Details
- 
isDirected
public boolean isDirected()Always returnsfalseas this is an undirected edge.- Specified by:
 isDirectedin classEdge<T>- Returns:
 false
 - 
getNode1
Get the first node of this edge. Whether a node is the first of second node does not mean anything, i.e. order of nodes is arbitrary in an undirected edge. - 
getNode2
Get the second node of this edge. Whether a node is the first of second node does not mean anything, i.e. order of nodes is arbitrary in an undirected edge. - 
toString
Create a string representation of the undirected edge, formatted as {a,b}. 
 -