scg.ac.ni.pmf.newgraph.graphdata
Class Vertex

java.lang.Object
  extended by scg.ac.ni.pmf.newgraph.graphdata.Vertex
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Element

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

Represents a graph vertex. Each vertex in a graph has a unique ID number. The additional properties of a vertex are the (X, Y) coordinates in the graphical representation of the graph.

Author:
Vladimir Brankov
See Also:
Serialized Form

Method Summary
 java.util.Set component()
          Retrieves the component that the vertex belongs to.
 int degree()
          Retrieves the degree of the vertex.
 void delete()
          Deletes the vertex.
 void deselect()
          Deselects this vertex.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is equal to this one.
 VertexData getData()
          Retrieves the vertex data of the vertex.
 int getID()
          Retrieves the identification number (ID) of the vertex.
 java.util.Set getIncident()
          Retrieves the set of edges incident with the specified vertex.
 java.util.Enumeration getNeighbors()
          Retrieves an enumeration of neighbors of the specified vertex.
 float getX()
          Retrieves the horizontal coordinate (X) of the vertex on the graphical representation of the graph.
 float getY()
          Retrieves the vertical coordinate (Y) of the vertex on the graphical representation of the graph.
 int hashCode()
          Returns a hash code value for the object.
 boolean isAdjanced(Vertex v)
          Retrieves is the vertex adjanced to the specified vertex.
 boolean isIncident(Edge e)
          Retrieves is the vertex incident with the specified edge.
 boolean isPrimarySelected()
          Retrieves is the vertex primary selected.
 boolean isSelected()
          Retrieves is the vertex selected.
 void moveFor(float dx, float dy)
          Moves the vertex for the specified distance.
 void moveTo(float x, float y)
          Moves the vertex to the specified coordinates.
 void select()
          Selects this vertex.
 void setPrimarySelected()
          Sets the vertex as primary selected.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is equal to this one.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

getID

public int getID()
Retrieves the identification number (ID) of the vertex. The ID is unique for each vertex of the graph.

Returns:
int The ID.

getX

public float getX()
Retrieves the horizontal coordinate (X) of the vertex on the graphical representation of the graph.

Returns:
float The X coordinate.

getY

public float getY()
Retrieves the vertical coordinate (Y) of the vertex on the graphical representation of the graph.

Returns:
float The Y coordinate.

getData

public VertexData getData()
Retrieves the vertex data of the vertex.

Returns:
VertexData The vertex data.

isAdjanced

public boolean isAdjanced(Vertex v)
Retrieves is the vertex adjanced to the specified vertex.

Parameters:
v - The vertex.
Returns:
boolean Indicates is the vertex adjanced to the specified vertex.

isIncident

public boolean isIncident(Edge e)
Retrieves is the vertex incident with the specified edge.

Parameters:
e - The edge.
Returns:
boolean Indicates is the vertex incident to the specified edge.

isSelected

public boolean isSelected()
Retrieves is the vertex selected.

Specified by:
isSelected in interface Element
Returns:
boolean Indicates whether the vertex is selected.

isPrimarySelected

public boolean isPrimarySelected()
Retrieves is the vertex primary selected.

Returns:
boolean Indicates whether the vertex is primary selected.

getNeighbors

public java.util.Enumeration getNeighbors()
Retrieves an enumeration of neighbors of the specified vertex.

Returns:
Enumeration An enumeration of Vertex.

getIncident

public java.util.Set getIncident()
Retrieves the set of edges incident with the specified vertex. If the vertex does not exist, returns null.

Returns:
Collection A collection of Edge.

delete

public void delete()
Deletes the vertex.

Specified by:
delete in interface Element
See Also:
Element.delete()

select

public void select()
Selects this vertex.

Specified by:
select in interface Element

deselect

public void deselect()
Deselects this vertex.

Specified by:
deselect in interface Element

setPrimarySelected

public void setPrimarySelected()
Sets the vertex as primary selected.

Specified by:
setPrimarySelected in interface Element
See Also:
Element.setPrimarySelected()

moveTo

public void moveTo(float x,
                   float y)
Moves the vertex to the specified coordinates.

Parameters:
x - The horizontal (X) coordinate.
y - The vertical (Y) coordinate.

moveFor

public void moveFor(float dx,
                    float dy)
Moves the vertex for the specified distance.

Parameters:
dx - The horizontal (X) distance.
dy - The vertical (Y) distance.

degree

public int degree()
Retrieves the degree of the vertex.

Returns:
int The degree.

component

public java.util.Set component()
Retrieves the component that the vertex belongs to.

Returns:
Set The set of Vertex.


Copyright © 2004 Dragan Stevanovic, Vladimir Brankov.