graph
Interface Graph


public interface Graph


Method Summary
 boolean addEdge(java.lang.Object from, java.lang.Object to)
          Adds a new edge from the vertex from to the vertex to.
 boolean addVertex(java.lang.Object vertex)
          Adds a new vertex to this graph.
 java.util.Set getAdjacentVertices(java.lang.Object vertex)
          Returns a set of all adjacent vertices of vertex.
 int getNofEdges()
          Returns the number of edges in this graph.
 int getNofVertices()
          Returns the number of vertices of this graph.
 java.util.Set getVertices()
          Returns a set of all objects refered to by all vertices in this graph.
 boolean isDirected()
          Is this graph directed?
 boolean removeEdge(java.lang.Object from, java.lang.Object to)
          Removes the edge between the vertex from and to.
 

Method Detail

addVertex

public boolean addVertex(java.lang.Object vertex)
Adds a new vertex to this graph. Vertices are unique within a graph.
Parameters:
vertex - the new node to be added.
Returns:
whether a new vertex could be added to this graph.

addEdge

public boolean addEdge(java.lang.Object from,
                       java.lang.Object to)
Adds a new edge from the vertex from to the vertex to. from and to must already be vertices of this graph. If the graph is undirected, then an edge from to to from will be inserted as well. There can be no multiple edges between two vertices, i.e. if there exists already an edge between from and to, nothing will be done.
Parameters:
from - add a new edge from the vertex from.
to - add a new edge to the vertex to.
Returns:
false if from or to do not exist or if there is already an edge from from to to, returns true otherwise (edge was successfully added).

removeEdge

public boolean removeEdge(java.lang.Object from,
                          java.lang.Object to)
Removes the edge between the vertex from and to. If there is no such vertex or from or to do not exist nothing will be done. If the graph is undirected, then the edge from to to from will be removed as well.
Parameters:
from - remove edge from the vertex from.
to - remove edge to the vertex to.
Returns:
false if from or to do not exist or if there was no edge from from to to, returns true otherwise (edge between from and to was successfully removed).

isDirected

public boolean isDirected()
Is this graph directed?
Returns:
true if the graph is directed, false otherwise

getNofVertices

public int getNofVertices()
Returns the number of vertices of this graph.
Returns:
the number of vertices.

getNofEdges

public int getNofEdges()
Returns the number of edges in this graph.
Returns:
the number of edges.

getVertices

public java.util.Set getVertices()
Returns a set of all objects refered to by all vertices in this graph.

getAdjacentVertices

public java.util.Set getAdjacentVertices(java.lang.Object vertex)
Returns a set of all adjacent vertices of vertex.
Parameters:
vertex - we are interested in the adjacent vertices of vertex.
Returns:
a set of all adjacent vertices of vertex.