visidia.graph
Class Vertex

java.lang.Object
  extended by visidia.misc.property.PropertyTable
      extended by visidia.graph.Vertex
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Sensor, SupportVertex

public class Vertex
extends PropertyTable

The Class Vertex represents a graph vertex by a unique identifier. A vertex knows both its neighbors and its incident edges. There is at most one edge between two vertices. A vertex can have a set of properties, stored in a whiteboard (property table).

See Also:
Serialized Form

Field Summary
protected  java.util.Vector<Edge> edges
          The incident edges.
protected  java.util.Vector<Vertex> neighbors
          The neighbors.
 
Constructor Summary
protected Vertex(int id)
          Instantiates a new vertex.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this vertex (shallow copy).
 int degree()
          Computes the vertex degree as the number of its neighbors.
 int getDoorTo(Vertex v)
          Gets the door through which this vertex goes to v.
 Edge getEdge(Vertex v)
          Gets the edge incident to vertex v and this.
 java.util.Enumeration<Edge> getEdges()
          Gets the incident edges.
 int getId()
          Gets the vertex id.
 java.lang.String getLabel()
          Gets the label.
 Vertex getNeighborByDoor(int door)
          Gets the neighbor associated to the door.
 java.util.Enumeration<Vertex> getNeighbors()
          Gets the neighbors.
 boolean isSwitchedOn()
          Checks if is switched on.
 Edge linkTo(Vertex v, boolean oriented)
          Links to another vertex (create an edge).
 void merge(Vertex v)
          Merges vertex v to this.
 void removeIncidentEdges()
          Removes the incident edges.
 void resetProperties()
          Reset properties.
 void setId(int id)
          Sets the vertex id.
 void setLabel(java.lang.String label)
          Sets the label.
 java.lang.Object setProperty(VisidiaProperty property)
          Sets a property.
 void setSwitchedOn(boolean switchedOn)
          Switches the vertex on/off.
 void unlink(Vertex v)
          Unlinks this vertex and vertex v.
 
Methods inherited from class visidia.misc.property.PropertyTable
containsElement, entrySet, getLockOwner, getPropertyKeys, getVisidiaProperty, isPersistentProperty, locked, lockProperties, removeProperty, setProperties, setVisidiaProperty, unlockProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

neighbors

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


edges

protected java.util.Vector<Edge> edges
The incident edges.

Constructor Detail

Vertex

protected Vertex(int id)
Instantiates a new vertex.

Parameters:
id - the vertex id
Method Detail

linkTo

public Edge linkTo(Vertex v,
                   boolean oriented)
Links to another vertex (create an edge).

Parameters:
v - the vertex to be linked to.
oriented - the oriented
Returns:
the created edge

getEdge

public Edge getEdge(Vertex v)
Gets the edge incident to vertex v and this.

Parameters:
v - the vertex
Returns:
the incident edge, or null if the vertices are not connected

unlink

public void unlink(Vertex v)
Unlinks this vertex and vertex v.

Parameters:
v - a vertex.

getNeighbors

public java.util.Enumeration<Vertex> getNeighbors()
Gets the neighbors.

Returns:
the neighbors

getNeighborByDoor

public Vertex getNeighborByDoor(int door)
Gets the neighbor associated to the door.

Parameters:
door - the door
Returns:
the neighbor

getDoorTo

public int getDoorTo(Vertex v)
Gets the door through which this vertex goes to v.

Parameters:
v - the v
Returns:
the door, or -1 if the two vertices are not connected

getEdges

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

Returns:
the incident edges

getId

public int getId()
Gets the vertex id.

Returns:
the id

setId

public void setId(int id)
Sets the vertex id.

Parameters:
id - the new id

degree

public int degree()
Computes the vertex degree as the number of its neighbors.

Returns:
the degree

removeIncidentEdges

public void removeIncidentEdges()
Removes the incident edges.


merge

public void merge(Vertex v)
Merges vertex v to this.

Parameters:
v - the vertex

clone

public java.lang.Object clone()
Returns a clone of this vertex (shallow copy).

Overrides:
clone in class PropertyTable
Returns:
a clone of this vertex
See Also:
Object.clone()

resetProperties

public void resetProperties()
Reset properties.

Overrides:
resetProperties in class PropertyTable

setProperty

public java.lang.Object setProperty(VisidiaProperty property)
Sets a property.

Parameters:
property - the property
Returns:
the previous property value of the specified key in this hashtable, or null if it did not have one.

getLabel

public java.lang.String getLabel()
Gets the label.

Returns:
the label

setLabel

public void setLabel(java.lang.String label)
Sets the label.

Parameters:
label - the new label

isSwitchedOn

public boolean isSwitchedOn()
Checks if is switched on.

Returns:
true, if is switched on

setSwitchedOn

public void setSwitchedOn(boolean switchedOn)
Switches the vertex on/off.

Parameters:
switchedOn - the switched on