jwo.landserf.structure.msn
Class GraphJunction

java.lang.Object
  extended byjwo.landserf.structure.msn.GraphJunction

public class GraphJunction
extends Object

Structure to store a graph junction. Stores a reference to the junction node and any directly connected edges in clockwise order.

Version:
2.2, 29th March, 2003.
Author:
Jo Wood

Constructor Summary
GraphJunction(GraphNode node, Vector edges)
          Creates a graph junction with the given edges at the given node.
 
Method Summary
 boolean addEdge(GraphEdge newEdge)
          Adds the given edge to the end of the edge list at the junction.
 boolean addEdges(Vector newEdges)
          Adds the given list of edges to the the junction.
 GraphNode getCentreNode()
          Returns the central node at this junction.
 Vector getEdges()
          Returns a list of edges connected to this junction.
 GraphNode getLeftNode(GraphNode node)
          Returns the node to the 'left' (clockwise) of the given node, or null if the given node is not found.
 Vector getNodes()
          Returns a list of nodes connected to the central node.
 GraphNode getRightNode(GraphNode node)
          Returns the node to the 'right' (anticlockwise) of the given node, or null if the given node is not found.
 int getValency()
          Reports the valency of the junction (should be at least 2).
 boolean removeEdge(GraphEdge edgeToRemove)
          Removes the given edge from the junction.
 String toString()
          Provides a text summary of the junction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphJunction

public GraphJunction(GraphNode node,
                     Vector edges)
Creates a graph junction with the given edges at the given node.

Parameters:
node - Node forming junction.
edges - List of edges joining at this node. Edges should be listed in clockwise order.
Method Detail

addEdges

public boolean addEdges(Vector newEdges)
Adds the given list of edges to the the junction. Edges are assumed to be listed in clockwise order. Checks that one of the nodes in each edge matches the junctionNode before it is added.

Parameters:
newEdges - List of new edges to add to junction.
Returns:
True if all edges added successfully, false if any edge does not contain the junction node.

addEdge

public boolean addEdge(GraphEdge newEdge)
Adds the given edge to the end of the edge list at the junction. Checks that one of the nodes in the edge matches the junctionNode before it is added.

Parameters:
newEdge - New edge to add to junction.
Returns:
True if edge added successfully, false if edge does not contain the junction node.

removeEdge

public boolean removeEdge(GraphEdge edgeToRemove)
Removes the given edge from the junction.

Parameters:
edgeToRemove - Edge to remove from junction.
Returns:
True if edge sucessfully removed, otherwise false.

toString

public String toString()
Provides a text summary of the junction.

Returns:
String representation of the edge

getLeftNode

public GraphNode getLeftNode(GraphNode node)
Returns the node to the 'left' (clockwise) of the given node, or null if the given node is not found. If junction consists of only one edge, the given node is returned.

Parameters:
node - Node to search from.
Returns:
Node to the left (clockwise) of the given one.

getRightNode

public GraphNode getRightNode(GraphNode node)
Returns the node to the 'right' (anticlockwise) of the given node, or null if the given node is not found. If junction consists of only one edge, the given node is returned.

Parameters:
node - Node to search from.
Returns:
Node to the right (anticlockwise) of the given one.

getCentreNode

public GraphNode getCentreNode()
Returns the central node at this junction.

Returns:
Central node at this junction.

getNodes

public Vector getNodes()
Returns a list of nodes connected to the central node. Does not return the central node itself.

Returns:
List of nodes connected at this junction.

getEdges

public Vector getEdges()
Returns a list of edges connected to this junction.

Returns:
List of connected edges at this junction.

getValency

public int getValency()
Reports the valency of the junction (should be at least 2).

Returns:
Valency of junction.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005