visidia.graph
Class Graph

java.lang.Object
  extended by visidia.graph.Graph
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
SensorGraph

public class Graph
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The Class Graph manages a graph as a set of vertices.

See Also:
Serialized Form

Field Summary
protected  int numberOfCreatedVertices
          The number of created vertices.
protected  java.util.Vector<Vertex> vertices
          The vertices.
 
Constructor Summary
Graph()
          Instantiates a new graph.
 
Method Summary
 void addVertex(Vertex vertex)
          Adds the vertex.
 java.lang.Object clone()
          Returns a clone of this graph (deep copy).
 int[] computeDistancesFrom(Vertex vertex)
          Compute the distances (in number of edges) from this vertex to other vertices in graph.
 Vertex createVertex()
          Creates a vertex.
 Vertex createVertex(int id)
          Creates a vertex with specific id.
 java.util.Enumeration<Edge> getEdges()
          Gets the edges.
 int getNbEdges()
          Computes the number of edges in the graph.
 Vertex getVertex(int id)
          Gets the vertex with this id.
 java.util.Enumeration<Vertex> getVertices()
          Gets the vertices.
 int order()
          Computes the graph order as the number of vertices in the graph.
 void removeVertex(Vertex vertex)
          Removes the vertex.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

protected java.util.Vector<Vertex> vertices
The vertices.


numberOfCreatedVertices

protected int numberOfCreatedVertices
The number of created vertices.

Constructor Detail

Graph

public Graph()
Instantiates a new graph.

Method Detail

createVertex

public Vertex createVertex()
Creates a vertex.

Returns:
the created vertex

createVertex

public Vertex createVertex(int id)
Creates a vertex with specific id. Use carefully! Vertex id must be unique!

Parameters:
id - the vertex id
Returns:
the created vertex

addVertex

public void addVertex(Vertex vertex)
Adds the vertex.

Parameters:
vertex - the vertex

removeVertex

public void removeVertex(Vertex vertex)
Removes the vertex.

Parameters:
vertex - the vertex

getVertex

public Vertex getVertex(int id)
Gets the vertex with this id.

Parameters:
id - the vertex id
Returns:
the vertex

getVertices

public java.util.Enumeration<Vertex> getVertices()
Gets the vertices.

Returns:
the vertices

getEdges

public java.util.Enumeration<Edge> getEdges()
Gets the edges.

Returns:
the edges

order

public int order()
Computes the graph order as the number of vertices in the graph.

Returns:
the order

getNbEdges

public int getNbEdges()
Computes the number of edges in the graph.

Returns:
the number of edges

clone

public java.lang.Object clone()
Returns a clone of this graph (deep copy).

Overrides:
clone in class java.lang.Object
Returns:
a clone of this graph
See Also:
Object.clone()

computeDistancesFrom

public int[] computeDistancesFrom(Vertex vertex)
Compute the distances (in number of edges) from this vertex to other vertices in graph.

Parameters:
vertex - the first vertex
Returns:
the array of distances