

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
public interface Graph
A Graph
consists of a set of nodes and a set of edges. These two
sets are not ordered. A Graph
is considered directed iff all its
edges are directed, undirected iff all its edges are undirected. A
Graph
may contain directed and undirected edges. It can only be
directed and undirected at the same time iff it is empty. Graphs can be
copied. The methode copy()
of the interface
org.graffiti.core.DeepCopy
returns a copy of the
Graph
which contains no references to the original
Graph
any more. Every Graph
implementation
implements this interface. Graph
implementations are to be
observable. This is required e.g. for visualisation. For this reason every
Graph
instance contains a ListenerManager
which
provides the required functionality. To use this functionality all methods
modifying the Graph
should inform the
ListenerManager
.
Implementation notes: For example, the method xy()
of any
Graph
implementation will have to look as follows:
public whatever xy() { GraphEvent ge = new GraphEvent(...); listenerManager.preXy(g); // ... // here comes the functionality of method xy // ... ge = new GraphEvent(...); listenerManager.postXy(g); return ... ; }
Node
,
Edge
,
Attributable
Method Summary  

void 
addAttributeConsumer(AttributeConsumer attConsumer)
Adds the given attribute consumer to the list of attribute consumers. 
Edge 
addEdge(Node source,
Node target,
boolean directed)
Adds a new Edge to the current Graph . 
Edge 
addEdge(Node source,
Node target,
boolean directed,
CollectionAttribute col)
Adds a new Edge to the current Graph . 
Edge 
addEdgeCopy(Edge edge,
Node source,
Node target)
Adds a copy of the specified Edge to the Graph
as a new Edge between the specified source and target
Node . 
void 
addGraph(Graph g)
Adds a Graph g to the current Graph . 
Node 
addNode()
Adds a new Node to the Graph . 
Node 
addNode(CollectionAttribute col)
Adds a new node to the graph. 
Node 
addNodeCopy(Node node)
Adds a copy of the specified Node to the Graph . 
void 
clear()
Deletes the current Graph by resetting all its attributes. 
boolean 
containsEdge(Edge e)
Returns true , if the Graph contains the
specified Edge , false otherwise. 
boolean 
containsNode(Node n)
Returns true , if the Graph contains the
specified Node , false otherwise. 
Edge 
createEdge(Node source,
Node target,
boolean directed,
CollectionAttribute col)
Creates a new Edge without actually adding it to the Graph. 
Node 
createNode(CollectionAttribute col)
Creates a new node using the given attributeobject without actually adding the created Node to the graph. 
void 
deleteEdge(Edge e)
Deletes Edge e from the current Graph . 
void 
deleteNode(Node n)
Deletes the Node n. 
AttributeTypesManager 
getAttTypesManager()
Returns the AttributeTypesManager of the Graph . 
Collection<Edge> 
getEdges()
Returns all edges of the graph. 
Collection<Edge> 
getEdges(Node n1,
Node n2)
Returns a collection containing all the edges between n1 and n2. 
Iterator<Edge> 
getEdgesIterator()
Returns an iterator over the edges of the Graph . 
Collection<GraphElement> 
getGraphElements()
Returns all nodes and all edges contained in this graph. 
List<Node> 
getNodes()
Returns all nodes of the graph. 
Iterator<Node> 
getNodesIterator()
Returns an iterator over the nodes of the graph. 
int 
getNumberOfDirectedEdges()
Returns the number of directed edges of the Graph . 
int 
getNumberOfEdges()
Returns the number of edges of the Graph . 
int 
getNumberOfNodes()
Returns the number of nodes in the Graph . 
int 
getNumberOfUndirectedEdges()
Returns the number of undirected edges in the Graph . 
boolean 
isDirected()
Indicates whether the Graph is directed. 
boolean 
isEmpty()
Returns true if the Graph is empty. 
boolean 
isModified()
Indicates whether the Graph has been modified. 
boolean 
isUndirected()
Indicates whether the Graph is undirected. 
boolean 
removeAttributeConsumer(AttributeConsumer attConsumer)
Returns true , if the given attribute consumer was in the
list of attribute consumers and could be removed. 
void 
setDirected(boolean directed)
When passing a true value, all undirected edges in the graph will be set to be directed. 
void 
setDirected(boolean directed,
boolean adjustArrows)
When passing a true value, all undirected edges in the graph will be set to be directed. 
void 
setModified(boolean modified)
Should be set to False after saving changes and to True after making changes to the Graph. 
Methods inherited from interface org.graffiti.attributes.Attributable 

addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString 
Methods inherited from interface org.graffiti.core.DeepCopy 

copy 
Method Detail 

AttributeTypesManager getAttTypesManager()
AttributeTypesManager
of the Graph
.
AttributeTypesManager
of the Graph
.boolean isDirected()
Graph
is directed. A
Graph
is directed if all the edges are directed.
true
if the Graph
is directed
false
otherwise.boolean isModified()
Graph
has been modified. A call to
setModified
can change this property to false e.g. after the
graph has been saved to disc. Changes to attributes and delete/add
commands of nodes and edges should change this property to
true
.
void setModified(boolean modified)
modified
 Indicates the new status of this field.void setDirected(boolean directed)
directed
 void setDirected(boolean directed, boolean adjustArrows)
directed
 adjustArrows
 Collection<Edge> getEdges()
Collection<Edge> getEdges(Node n1, Node n2)
Edge
between two nodes. The edges
returned by this method can go from n1 to n2 or vice versa, be directed
or not.
n1
 the first Node
n2
 the second Node
Collection
containing all edges between n1 and n2,
an empty collection if there is no Edge
between the
two nodes.
GraphElementNotFoundException
 if one of the nodes is not contained in the graph.Iterator<Edge> getEdgesIterator()
Graph
.
Graph
.boolean isEmpty()
true
if the Graph
is empty. E.g. the
Graph
is equal to a Graph
which has been
cleared.
true
if the Graph
is empty,
false
otherwise.Collection<GraphElement> getGraphElements()
List<Node> getNodes()
Iterator<Node> getNodesIterator()
Iterator.remove()
operation.
int getNumberOfDirectedEdges()
Graph
.
Graph
.int getNumberOfEdges()
Graph
.
Graph
.int getNumberOfNodes()
Graph
.
Graph
.int getNumberOfUndirectedEdges()
Graph
.
Graph
.boolean isUndirected()
Graph
is undirected. A
Graph
is undirected if all the edges are undirected.
true
if the Graph
is undirected,
false
otherwise.void addAttributeConsumer(AttributeConsumer attConsumer) throws UnificationException
attConsumer
 the attribute consumer to add.
UnificationException
Edge addEdge(Node source, Node target, boolean directed) throws GraphElementNotFoundException
Edge
to the current Graph
. Informs
the ListenerManager about the new Edge
.
source
 the source of the Edge
to add.target
 the target of the Edge
to add.directed
 true
if the Edge
shall be directed,
false
otherwise.
Edge
.
GraphElementNotFoundException
 if any of the nodes cannot be found in the
Graph
.Edge addEdge(Node source, Node target, boolean directed, CollectionAttribute col) throws GraphElementNotFoundException
Edge
to the current Graph
. Informs
the ListenerManager about the new Edge
.
source
 the source of the Edge
to add.target
 the target of the Edge
to add.directed
 true
if the Edge
shall be directed,
false
otherwise.col
 the CollectionAttribute
this edge is initialized
with.
Edge
.
GraphElementNotFoundException
 if any of the nodes cannot be found in the
Graph
.Edge createEdge(Node source, Node target, boolean directed, CollectionAttribute col)
source
 sourcenodetarget
 targetnodedirected
 shall the new edge be directed?col
 attributes for the new edge
Edge addEdgeCopy(Edge edge, Node source, Node target)
Edge
to the Graph
as a new Edge
between the specified source and target
Node
. Informs the ListenerManager about the newly added
Edge
. Also informs the ListenerManager about the copy of the
attributes added to the Edge
.
edge
 the Egde
which to copy and add.source
 the source Node
of the copied and added
Edge
.target
 the target Node
of the copied and added
Edge
.
void addGraph(Graph g)
Graph
g to the current Graph
.
Graph
g will be copied and then all its nodes and edges will
be added to the current Graph
. Like this g will not be
destroyed.
g
 the Graph
to be added.Node addNode()
Node
to the Graph
. Informs the
ListenerManager about the new Node
.
Node
.Node addNode(CollectionAttribute col)
col
 the CollectionAttribute
the node is initialized
with.
Node createNode(CollectionAttribute col)
col
 attributes for the new node
Node addNodeCopy(Node node)
Node
to the Graph
.
Informs the ListenerManager about the newly added Node
in
the same way as if a completely new Node
was added. Also
informs the ListenerManager about the addition of attributes.
node
 the Node
which to copy and to add.
void clear()
Graph
by resetting all its attributes.
The Graph
is then equal to a newly generated
Graph
.
boolean containsEdge(Edge e)
true
, if the Graph
contains the
specified Edge
, false
otherwise.
e
 the Edge
to seach for
true
, if the Graph
contains the
specified Edge
, false
otherwise.boolean containsNode(Node n)
true
, if the Graph
contains the
specified Node
, false
otherwise.
n
 the Node
to search for.
true
, if the Graph
contains the
Node
n, false
otherwise.void deleteEdge(Edge e) throws GraphElementNotFoundException
Edge
e from the current Graph
. Informs
the ListenerManager about the deletion.
e
 the Edge
to delete.
GraphElementNotFoundException
 if the Edge
to delete cannot be found in the
Graph
.void deleteNode(Node n) throws GraphElementNotFoundException
Node
n. All in and outgoing edges will be
deleted. Informs the ListenerManager about the deletion of the
Node
and the concerned edges.
n
 the Node
to delete.
GraphElementNotFoundException
 if the Node
to delete cannot be found in the
Graph
.boolean removeAttributeConsumer(AttributeConsumer attConsumer)
true
, if the given attribute consumer was in the
list of attribute consumers and could be removed.
true
, if the given attribute consumer was in the
list of attribute consumers and could be removed.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 