annas.graph
Interface GraphInterface<N,A extends ArcInterface<N>>

Type Parameters:
N - Node type
A - Arc type
All Known Implementing Classes:
DirectedGraph, Graph, UndirectedGraph

public interface GraphInterface<N,A extends ArcInterface<N>>

Base interface for all Graphs

Author:
Sam Wilson

Method Summary
 boolean addArc(N tail, N head, WeightedInterface wi)
          Adds an arc to the graph
 boolean addNode(N node)
          Adds a node to the graph
 boolean contains(N node)
          Checks if the graph contains a node
 java.util.ArrayList<A> getArc(N tail)
          Gets all arcs which originate from the given node
 java.util.ArrayList<A> getArc(N tail, N head)
          Gets all arcs from the tail to the head
 ArcFactory<N,A> getArcFactory()
          Gets the @see ArcFactory used by the graph
 java.util.ArrayList<N> getNodeMap()
          Gets a list of nodes in the graph
 int getNuArcs()
          Number of arcs contained within the graph
 int getNuNodes()
          Number of nodes contained within the graph
 GraphObserver getObserver()
          Current GraphObserver
 int getVersion()
          Gets the version of the graph.
 boolean removeArc(N tail)
          Removes all arcs with originating from a node
 boolean removeArc(N tail, A arc)
          Removes an arc from the graph
 boolean removeArc(N tail, N head)
          Removes all arc from the graph
 boolean removeNode(N node)
          Removes a node from the graph
 void resetArcs()
          Removes all arcs from the graph
 

Method Detail

addNode

boolean addNode(N node)
Adds a node to the graph

Parameters:
node - to add to the graph
Returns:

removeNode

boolean removeNode(N node)
Removes a node from the graph

Parameters:
node - to remove from the graph
Returns:
true if the node is successfully removed from the graph

contains

boolean contains(N node)
Checks if the graph contains a node

Parameters:
node - to check if it is contained within the graph
Returns:
true if the node is contained within the graph

addArc

boolean addArc(N tail,
               N head,
               WeightedInterface wi)
Adds an arc to the graph

Parameters:
tail - Tail of the arc
head - Head of the arc
wi - WeightedInterface
Returns:
true if the arc is successfully added to the graph

getArc

java.util.ArrayList<A> getArc(N tail)
Gets all arcs which originate from the given node

Parameters:
tail - tail of the arcs
Returns:
An arraylist of all arcs originating from the given nodes

getArc

java.util.ArrayList<A> getArc(N tail,
                              N head)
Gets all arcs from the tail to the head

Parameters:
tail - tail of the arc
head - head of the arc
Returns:
An arraylist of all arcs from the tail to the head

removeArc

boolean removeArc(N tail,
                  A arc)
Removes an arc from the graph

Parameters:
tail - tail of the arc to remove
arc - arc to remove
Returns:
true if the arc was successfully removed

removeArc

boolean removeArc(N tail,
                  N head)
Removes all arc from the graph

Parameters:
tail - tail of the arc to remove
head - head of the arc to remove
Returns:

removeArc

boolean removeArc(N tail)
Removes all arcs with originating from a node

Parameters:
tail - tail of the arc
Returns:
true if all arcs originating from the node were removed

resetArcs

void resetArcs()
Removes all arcs from the graph


getArcFactory

ArcFactory<N,A> getArcFactory()
Gets the @see ArcFactory used by the graph

Returns:
ArcFactory used by the graph

getNodeMap

java.util.ArrayList<N> getNodeMap()
Gets a list of nodes in the graph

Returns:
list of nodes in the graph

getObserver

GraphObserver getObserver()
Current GraphObserver

Returns:
GraphObserver

getVersion

int getVersion()
Gets the version of the graph. The graph version is initially 0, each method invoked which modifies the graph increments the field by 1.

Returns:

getNuArcs

int getNuArcs()
Number of arcs contained within the graph

Returns:

getNuNodes

int getNuNodes()
Number of nodes contained within the graph

Returns: