|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jclass.SyncSimpleGraph
Class that implements a simple graph providing primitives for
node connection handling. The class is designed only for providing
a PASIVE NODE solution, that is the nodes may not exist in reality
all that we do here is to store and retrieve fast and syncronized
connections between them, being able to also remove a node consistently
from the 'mesh' by removing all the connections that imply that node.
This class may be better called "connections container" because it
simply just STORES the connection without bothering about nodes more
than needed.
The graph allows also more connections between 2 nodes, with different
or equal metrics. It really does not care whether one node is or not
already connected to another. When a new connection request arrives in
via .connect() then it just enters the data into the appropriate
internal structs.
Written: Radu Sion
Version: 0.12 limited for overall testing
Source: SyncSimpleGraph.java
Visit
Smart Software
SyncSimpleArray
Constructor Summary | |
SyncSimpleGraph(int maxnodes)
Creating a new graph. |
Method Summary | |
void |
connect(int snode,
int dnode,
long metric,
long rtime)
Connects two (existing or not) nodes inside the graph. |
void |
disconnect(int snode,
int dnode)
Disables all connections between two nodes that match the given parameters. |
int |
getMaxNodes()
Returns the maximum nodes number that can be handled by this graph This also means that there can be NO node with an id greater than this value, stored inside this graph. |
java.util.Vector |
inConnections(int node)
Returns the incomming connections of a given node. |
int |
inConnectionsNumber(int node)
Returns the number of incomming connections of a given node. |
java.util.Vector |
outConnections(int node)
Returns the outgoing connections of a given node. |
int |
outConnectionsNumber(int node)
Returns the number of outgoing connections of a given node. |
void |
remove(int node)
Removes a node from the graph by removing all the connections that contain that node integer number. Devlp note: The respective slot is not deleted ! why should it be ? |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public SyncSimpleGraph(int maxnodes)
maxnodes
- Maximum number of expected nodes inside the graphMethod Detail |
public int getMaxNodes()
public void remove(int node)
node
- Node to removepublic void connect(int snode, int dnode, long metric, long rtime)
snode
- Source Node of that connectiondnode
- Destination Node of that connectionmetric
- Metric assigned to that connectionpublic void disconnect(int snode, int dnode)
snode
- Source Node of the Connection to removednode
- Destination Node of the Connection to removepublic java.util.Vector outConnections(int node)
node
- Node to take into accountpublic int outConnectionsNumber(int node)
node
- Node to take into accountpublic java.util.Vector inConnections(int node)
node
- Node to take into accountpublic int inConnectionsNumber(int node)
node
- Node to take into account
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |