|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.graph.core.GraphElement | +--gishur.graph.core.Node | +--gishur.graph.core.Graph
Field Summary | |
static boolean |
DIRECTED
Graph type constant indicating a directed Graph |
static boolean |
UNDIRECTED
Graph type constant indicating an undirected Graph |
Fields inherited from class gishur.graph.core.GraphElement |
ACCESS_CONNECT, ACCESS_REMOVE, BOTH, DETAILED, IN, LINK_ALL, NORMAL, OUT, SET_KEY, SET_VALUE, SHORT, VERY_DETAILED |
Fields inherited from interface gishur.core.ControlledCloneable |
DEEP, FLAT |
Constructor Summary | |
Graph()
Constructor of an undirected empty Graph without a name. |
|
Graph(boolean type)
Constructor of Graph of given type |
|
Graph(java.lang.String name)
Constructor of an undirected Graph . |
|
Graph(java.lang.String name,
boolean type)
Constructor for a Graph of given type type . |
Method Summary | |
void |
add(Edge e)
|
void |
add(Edge e,
Node a,
Node b)
|
void |
add(java.util.Enumeration enum)
|
void |
add(Node n)
|
protected boolean |
checkAccess(int access,
java.lang.Object argument)
Overridden GraphElement.checkAccess(int, java.lang.Object) method, working the
same way. |
void |
clear()
|
java.lang.Object |
clone(java.util.Hashtable h,
int level)
Clones this object. |
boolean |
contains(GraphElement e)
Checks if the Graph contains the given Node . |
static Graph |
createDirectedGraph()
Creates and returns a new Graph which is preset to be directed. |
static Graph |
createDirectedGraph(java.lang.String name)
Creates and returns a new Graph which is preset to be directed and has the
given name. |
static Graph |
createUndirectedGraph()
Creates and returns a new Graph which is preset to be undirected. |
static Graph |
createUndirectedGraph(java.lang.String name)
Creates and returns a new Graph which is preset to be undirected and has the
given name. |
boolean |
directed()
Returns DIRECTED if the graph is directed and UNDIRECTED
otherwise. |
Edge |
edge(int i)
Returns the i -th Edge of this Graph .
|
GraphCursor |
edges()
Creates and returns a GraphCursor which is able to navigate over the
Edges of this Graph . |
GraphCursor |
edges(Edge e)
Creates and returns a GraphCursor which is able to navigate over the
Edges of this Graph and whose starting position is
e . |
GraphCursor |
edges(Node u)
Creates and returns a GraphCursor which is able to move over the
Edges connected to u inside this Graph .
|
GraphCursor |
edges(Node u,
Edge e)
Creates and returns a GraphCursor which is able to move over the
Edges connected to u inside this Graph .
|
int |
edgesLength()
Returns the number of Edges of this Graph . |
protected java.lang.String |
edgesListToString(int level)
Returns a list of the Edges of the Graph in the form
"edge1,edge2,..." where "edgek" is the GraphElement.SHORT or GraphElement.NORMAL string
representation of the k-th Edge . |
GraphCursor |
inEdges(Node u)
Creates and returns a GraphCursor which is able to move over the
igoing Edges of u inside this Graph .
|
GraphCursor |
inEdges(Node u,
Edge e)
Creates and returns a GraphCursor which is able to move over the
ingoing Edges of u inside this Graph .
|
Node |
node(int i)
Returns the i -th Node of this Graph .
|
GraphCursor |
nodes()
Creates and returns a GraphCursor which is able to navigate over the
Nodes of this Graph . |
GraphCursor |
nodes(Node u)
Creates and returns a GraphCursor which is able to navigate over the
Nodes of this Graph and whose starting position is
u . |
int |
nodesLength()
Returns the number of Nodes of this Graph . |
protected java.lang.String |
nodesListToString(int level)
Returns a list of the Nodes of the Graph in the form
"node1,node2,..." where "nodek" is the GraphElement.SHORT string
representation of the k-th Node . |
GraphCursor |
outEdges(Node u)
Creates and returns a GraphCursor which is able to move over the
outgoing Edges of u inside this Graph .
|
GraphCursor |
outEdges(Node u,
Edge e)
Creates and returns a GraphCursor which is able to move over the
outgoing Edges of u inside this Graph .
|
void |
remove(Edge e)
|
void |
remove(Node u)
|
void |
removeEdgePropertiesStartingWith(java.lang.String key)
Removes the properties stored under keys starting with substring key
from all Edges of this Graph . |
void |
removeNodePropertiesStartingWith(java.lang.String key)
Removes the properties stored under keys starting with substring key
from all Nodes of this Graph . |
void |
removePropertyForAllEdges(java.lang.String key)
Removes the property stored under key key from all Edges
of this Graph . |
void |
removePropertyForAllNodes(java.lang.String key)
Removes the property stored under key key from all Nodes
of this Graph . |
boolean |
requestAccess(int access,
java.lang.Object trigger,
java.lang.Object obj)
Decides if an action on the graph is permitted or denied. |
boolean |
setDirected(boolean direct)
Makes the graph (un)directed. |
void |
setPropertyForAllEdges(java.lang.String key,
java.lang.Object o)
Sets the property defined by key for all
contained Edges of the Graph to value o .
|
void |
setPropertyForAllNodes(java.lang.String key,
java.lang.Object o)
Sets the property defined by key for all
contained Nodes of the Graph to value o .
|
void |
setSerialization(boolean serial)
This method marks Graphs to be serialized while a
serialization process. |
protected java.lang.String |
stateToString()
Returns the state of the Graph as a string. |
java.lang.String |
toString()
Returns a GraphElement.DETAILED string representation of the Graph . |
java.lang.String |
toString(int level,
int nodeLevel,
int edgeLevel)
Overridden toString method. |
Methods inherited from class gishur.graph.core.Node |
degree, generateName, inDegree, outDegree, preferredPosition, setPreferredPosition, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gishur.core.Cloneable |
clone |
Field Detail |
public static final boolean DIRECTED
Graph
type constant indicating a directed Graph
public static final boolean UNDIRECTED
Graph
type constant indicating an undirected Graph
Constructor Detail |
public Graph()
Graph
without a name.public Graph(java.lang.String name)
Graph
.name
- name of the Graphpublic Graph(boolean type)
Graph
of given typetype
- type of the Graph which can be DIRECTED or UNDIRECTEDpublic Graph(java.lang.String name, boolean type)
Graph
of given type type
.name
- name of the Graphtype
- type of the Graph which can be DIRECTED
or UNDIRECTED
Method Detail |
public static Graph createDirectedGraph()
Graph
which is preset to be directed.Graph
public static Graph createDirectedGraph(java.lang.String name)
Graph
which is preset to be directed and has the
given name.Graph
with name name
public static Graph createUndirectedGraph()
Graph
which is preset to be undirected.Graph
public static Graph createUndirectedGraph(java.lang.String name)
Graph
which is preset to be undirected and has the
given name.Graph
with name name
public java.lang.String toString(int level, int nodeLevel, int edgeLevel)
toString
method. It returns a String
representing this Graph
in a definable level of detail. The
various aspects of the Graph
which should be returned as a String
can be defined by level
. If level==GraphElement.SHORT
, only
the name of the Graph
will be returned. level==GraphElement.NORMAL
causes the method to return a string consistent of the name and the lists of Nodes
and Edges
of this Graph
. level==GraphElement.DETAILED
includes additionally a string representing the state, e.g. #DIRECTED_GRAPH
.
Finally, level==GraphElement.VERY_DETAILED
includes a additional list of
the properties. The argument edgeLevel
may be either GraphElement.SHORT
or GraphElement.NORMAL
and determines the level of detail in which the list of Edges
shall
be printed out.level
- a level constant, GraphElement.SHORT
,GraphElement.NORMAL
,
GraphElement.DETAILED
or GraphElement.VERY_DETAILED
, determining the requested level
of detailnodeLevel
- a level constant, GraphElement.SHORT
,GraphElement.NORMAL
,
GraphElement.DETAILED
or GraphElement.VERY_DETAILED
, determining the requested level
of detail for Nodes
edgeLevel
- a level constant, GraphElement.SHORT
,GraphElement.NORMAL
,
GraphElement.DETAILED
or GraphElement.VERY_DETAILED
, determining the requested level
of detail for Edges
String
for this Graph
public java.lang.String toString()
GraphElement.DETAILED
string representation of the Graph
.toString
in class GraphElement
GraphElement.DETAILED
string representation of the Graph
#toString(int,int)
protected java.lang.String nodesListToString(int level)
Nodes
of the Graph
in the form
"node1,node2,..." where "nodek" is the GraphElement.SHORT
string
representation of the k-th Node
.level
- a level constant, GraphElement.SHORT
,GraphElement.NORMAL
,
GraphElement.DETAILED
or GraphElement.VERY_DETAILED
, determining the requested level
of detailNodes
as a stringprotected java.lang.String edgesListToString(int level)
Edges
of the Graph
in the form
"edge1,edge2,..." where "edgek" is the GraphElement.SHORT
or GraphElement.NORMAL
string
representation of the k-th Edge
. The requested level of detail
is defined by level
, but only GraphElement.SHORT
or GraphElement.NORMAL
are
valid values. An invalid value is set to GraphElement.SHORT
.level
- a level constant, GraphElement.SHORT
,GraphElement.NORMAL
,
GraphElement.DETAILED
or GraphElement.VERY_DETAILED
, determining the requested level
of detailEdges
as a stringprotected java.lang.String stateToString()
Graph
as a string.public void add(Node n)
public void add(Edge e)
public void add(Edge e, Node a, Node b)
public void remove(Edge e)
public void remove(Node u)
public void add(java.util.Enumeration enum)
public void clear()
public GraphCursor edges()
GraphCursor
which is able to navigate over the
Edges
of this Graph
.GraphCursor
for this Graph
GraphCursor
public GraphCursor edges(Edge e)
GraphCursor
which is able to navigate over the
Edges
of this Graph
and whose starting position is
e
.GraphCursor
for this Graph
GraphCursor
public GraphCursor nodes()
GraphCursor
which is able to navigate over the
Nodes
of this Graph
.GraphCursor
for this Graph
GraphCursor
public GraphCursor nodes(Node u)
GraphCursor
which is able to navigate over the
Nodes
of this Graph
and whose starting position is
u
.GraphCursor
for this Graph
GraphCursor
public GraphCursor outEdges(Node u)
GraphCursor
which is able to move over the
outgoing Edges
of u
inside this Graph
.
The GraphCursor
is initially set to the first outgoing Edge
.u
- the Node
whose outgoing Edges
shall be
traversedGraphCursor
on the outgoing Edges
of u
public GraphCursor outEdges(Node u, Edge e)
GraphCursor
which is able to move over the
outgoing Edges
of u
inside this Graph
.
The GraphCursor
is initially set to e
, which must thus
be contained in this Graph
and must itself be an outgoing Edge
.
If one of these conditions is not fulfilled, a GraphException
will
occur.u
- the Node
whose outgoing Edges
shall be
traversede
- the initial position of the GraphCursor
GraphCursor
on the outgoing Edges
of u
public GraphCursor inEdges(Node u)
GraphCursor
which is able to move over the
igoing Edges
of u
inside this Graph
.
The GraphCursor
is initially set to the first igoing Edge
.u
- the Node
whose igoing Edges
shall be
traversedGraphCursor
on the ingoing Edges
of u
public GraphCursor inEdges(Node u, Edge e)
GraphCursor
which is able to move over the
ingoing Edges
of u
inside this Graph
.
The GraphCursor
is initially set to e
, which must thus
be contained in this Graph
and must itself be an ingoing Edge
.
If one of these conditions is not fulfilled, a GraphException
will
occur.u
- the Node
whose ingoing Edges
shall be
traversede
- the initial position of the GraphCursor
GraphCursor
on the ingoing Edges
of u
public GraphCursor edges(Node u)
GraphCursor
which is able to move over the
Edges
connected to u
inside this Graph
.
The GraphCursor
is initially set to the first Edge
.u
- the Node
whose adjacent Edges
shall be
traversedGraphCursor
on the Edges
adjacent to u
public GraphCursor edges(Node u, Edge e)
GraphCursor
which is able to move over the
Edges
connected to u
inside this Graph
.
The GraphCursor
is initially set to e
, which must thus
be contained in this Graph
and must itself be an adjacent Edge
.
If one of these conditions is not fulfilled, a GraphException
will
occur.u
- the Node
whose adjacent Edges
shall be
traversede
- the initial position of the GraphCursor
GraphCursor
on the Edges
adjacent to u
public boolean contains(GraphElement e)
Graph
contains the given Node
.Node
- node to testpublic int edgesLength()
Edges
of this Graph
.public int nodesLength()
Nodes
of this Graph
.public Edge edge(int i)
i
-th Edge
of this Graph
.
If i
represents an invalid index, null
will be returned.i
- the index of the {link Edge} to returni
-th Edge
of this Graph
public Node node(int i)
i
-th Node
of this Graph
.
If i
represents an invalid index, null
will be returned.i
- the index of the {link Node} to returni
-th Node
of this Graph
public boolean directed()
DIRECTED
if the graph is directed and UNDIRECTED
otherwise.public boolean setDirected(boolean direct)
direct
- if true
, the graph will be directed, otherwise
it will be undirectedpublic boolean requestAccess(int access, java.lang.Object trigger, java.lang.Object obj)
requestAccess
in interface Owner
access
- requested actiontrigger
- object which triggered the action.obj
- object on which the action should applyprotected boolean checkAccess(int access, java.lang.Object argument)
GraphElement.checkAccess(int, java.lang.Object)
method, working the
same way.checkAccess
in class Node
gishur.graph.core.Node
access
- an access constant specifying the requested operationargument
- the argument of the requested operationtrue
, if the operation is allowed, false
otherwisepublic void setPropertyForAllNodes(java.lang.String key, java.lang.Object o)
key
for all
contained Nodes
of the Graph
to value o
.
The method returns effectiveless if key==null
or o==null
.key
- key string defining which propery to seto
- further value of property s
public void setPropertyForAllEdges(java.lang.String key, java.lang.Object o)
key
for all
contained Edges
of the Graph
to value o
.
The method returns effectiveless if key==null
or o==null
.key
- key string defining which propery to seto
- further value of property s
public void removePropertyForAllNodes(java.lang.String key)
key
from all Nodes
of this Graph
. The method returns effectiveless if key==null
.key
- key string defining which property to removepublic void removePropertyForAllEdges(java.lang.String key)
key
from all Edges
of this Graph
. The method returns effectiveless if key==null
.key
- key string defining which property to removepublic void removeNodePropertiesStartingWith(java.lang.String key)
key
from all Nodes
of this Graph
. The method returns effectiveless if
key==null
.key
- key string defining which properties to removepublic void removeEdgePropertiesStartingWith(java.lang.String key)
key
from all Edges
of this Graph
. The method returns effectiveless if
key==null
.key
- key string defining which properties to removepublic java.lang.Object clone(java.util.Hashtable h, int level)
this
object. According to the parameter level
,
this
object will be cloned down to level
levels.
That means, the object will be cloned. If level==-1(==DEEP)
,
every object, which can be reached by traversing the references beginning
with /this object will be cloned if possible. This recursion
stopps, if there are no more objects to clone, or no reachable object implements
Cloneable. If level==1(==FLAT)
, no object contained by this
object will be cloned, but this
will be cloned. Only the references will be
maintained. If level>=0
, no objects will be cloned at all and this
will be returned.
The recursive cloning stopps, if there's a ring
structure. In this case, all Objects implementing Cloneable
are cloned,
and connected properly, so that even ring structures are cloned as rings.
A GraphElement's
cloning behaviour is somewhat special:
The lists containing the Owners
, linked GraphElements
and their link types are not cloned, but set to null
in
the cloned object. But the properties are cloned, i.e. all cloneable values they are
containing are cloned (not the keys!). The values which are not cloneable, will be
only referenced in the cloned properties list.
- Specified by:
clone
in interface ControlledCloneable
- Overrides:
clone
in class GraphElement
- Parameters:
h
- Hastable which containes all objects already cloned (with their original objects
as keys), to avoid multiple cloning of the same object (if h==null
a new Hashtable will be created - you can use null
to start a clone recursion)level
- indicates how many generations should be cloned recursive at most- Returns:
- the cloned Object
- Throws:
InternalError
- - if the Object could not be cloned properly
public void setSerialization(boolean serial)
Graphs
to be serialized while a
serialization process. On writing a Graph
to a stream, this
Graph
will be marked (with serial=true
). But all
connected Graphs
(like additional owners of some elements)
will not be written, except they are marked for serialization too (this
may be the case if they are already written to streams). To enable a
Graph
to be serialized or to prevent serialization, one may use
this method to mark/unmark Graphs
for serialization.serial
- if true
, the Graph
will be serialized
otherwise it prevents serialization
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |