|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--Vertex
This class has been designed to test self-stabilizing algorithms.
In a model of self-stabilization each vertex has its state.
Having this state and information about states of its neighbors
vertex can determine(agree()) if it should change its state(is enabled) or not.
In first case vertex makes a move(change its state move(int)), in second stays without changing state.
We consider a set of vertices connected in some way with edges.
Such a structure we call a (Graph).
To show this structure to the user we have to place vertices somehow.
Each vertex has its coordinates in a virtual Panel.
Dimension of this rectangular panel is given by points (0,0) (Graph.MAXX, Graph.MAXY).
Of course when program runs we have to adjust this coordinates to screen Panel dimensions (Graph.setFactors(int, int)).
| Field Summary | |
protected java.util.HashSet |
neighbors
All neighbors of a vertex in a graph |
float |
xFactor
This factor allows to adjust screen Vertex x coordinate . |
float |
yFactor
This factor allows to adjust screen Vertex y coordinate . |
| Constructor Summary | |
Vertex()
|
|
Vertex(java.lang.String name)
|
|
Vertex(java.lang.String name,
int radius)
|
|
| Method Summary | |
boolean |
addEdge(Vertex u)
|
abstract boolean |
agree()
This method should determine if vertex state agrees to rules of a specified algorithm |
java.lang.Object |
clone()
This method works properly only with vertices without edges. |
int |
deg()
Return vertex degree in a graph |
double |
distance(int x,
int y)
Count a distance between given point (x,y) and Vertex coordinates (getXCoordinate(),getYCoordinate) in screen pixels. |
java.lang.String |
getInfo()
returns a String describing Vertex |
java.lang.String |
getName()
|
int |
getRadius()
Gets radius in pixels. |
abstract java.lang.String |
getStateInfo()
This method should get a state info of a vertex. |
int |
getXCoordinate()
Gets the x coordinate |
int |
getYCoordinate()
Gets the y coordinate |
java.util.Iterator |
iterator()
Iterator over the neighbors of a vertex. |
abstract void |
move(int info)
This method should make a move assuming that vertex is enabled. |
void |
paintState(java.awt.Graphics graphics)
This method should paint a vertex according to its state, however in Vertex class it just paint circles with radius in red. |
void |
print()
Print vertex info. |
abstract void |
printState()
This method should print a state of a vertex. |
abstract void |
randomState(java.util.Random r)
This method should random a state of a vertex. |
void |
setCoordinates(int x,
int y)
Sets vertex coordinate a |
void |
setFactors(float x,
float y)
Sets vertex factors |
void |
setName(java.lang.String name)
|
void |
setRadius(int radius)
Sets radius in pixels. |
void |
setXCoordinate(int x)
Sets the x coordinate |
void |
setYCoordinate(int y)
Sets the y coordinate |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public float xFactor
Vertexpublic float yFactor
Vertexprotected java.util.HashSet neighbors
| Constructor Detail |
public Vertex()
public Vertex(java.lang.String name)
public Vertex(java.lang.String name,
int radius)
| Method Detail |
public void setXCoordinate(int x)
x - coordinate in screen pixelsVertexpublic void setYCoordinate(int y)
y - coordinate in screen pixelsVertex
public void setCoordinates(int x,
int y)
x - X coordinates in screen pixelsy - Y coordinates in screen pixelsVertexpublic int getXCoordinate()
Vertexpublic int getYCoordinate()
Vertexpublic void setRadius(int radius)
radius - length of radius in screen pixelsVertexpublic int getRadius()
Vertex
public void setFactors(float x,
float y)
x - X factory - Y factorVertex
public double distance(int x,
int y)
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic java.lang.String getInfo()
VertexInfoDialogpublic void print()
Graph.print()public java.lang.String getName()
public void setName(java.lang.String name)
public boolean addEdge(Vertex u)
public int deg()
Graph.delta()public java.util.Iterator iterator()
public void paintState(java.awt.Graphics graphics)
setRadius(int),
Graph.paintStates(java.awt.Graphics)public abstract boolean agree()
public abstract void move(int info)
public abstract void randomState(java.util.Random r)
public abstract void printState()
public abstract java.lang.String getStateInfo()
VertexInfoDialog
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||