org.graffiti.graph
Interface Graph

All Superinterfaces:
Attributable, DeepCopy
All Known Implementing Classes:
AbstractGraph, AdjListGraph, FastGraph, OptAdjListGraph

public interface Graph
extends Attributable, DeepCopy

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 ... ;
            }
 

Version:
$Revision: 5767 $
See Also:
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 attribute-object 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

getAttTypesManager

AttributeTypesManager getAttTypesManager()
Returns the AttributeTypesManager of the Graph.

Returns:
the AttributeTypesManager of the Graph.

isDirected

boolean isDirected()
Indicates whether the Graph is directed. A Graph is directed if all the edges are directed.

Returns:
true if the Graph is directed false otherwise.

isModified

boolean isModified()
Indicates whether the 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.

Returns:
True, if the graph has been modifed, False if not.

setModified

void setModified(boolean modified)
Should be set to False after saving changes and to True after making changes to the Graph. The add/delete nodes and edges commands as well as the property change methods should set this value to True.

Parameters:
modified - Indicates the new status of this field.

setDirected

void setDirected(boolean directed)
When passing a true value, all undirected edges in the graph will be set to be directed. V.v. for a false value.

Parameters:
directed -

setDirected

void setDirected(boolean directed,
                 boolean adjustArrows)
When passing a true value, all undirected edges in the graph will be set to be directed. V.v. for a false value. A true second parameter indicates that all edges shall get one arrow at their tips (i.e. close to the target node).

Parameters:
directed -
adjustArrows -

getEdges

Collection<Edge> getEdges()
Returns all edges of the graph. The returned collection may be unmodifiable and is only valid as long as the graph is not modified.

Returns:
a list of all edges of the graph.

getEdges

Collection<Edge> getEdges(Node n1,
                          Node n2)
Returns a collection containing all the edges between n1 and n2. There can be more than one Edge between two nodes. The edges returned by this method can go from n1 to n2 or vice versa, be directed or not.

Parameters:
n1 - the first Node
n2 - the second Node
Returns:
a Collection containing all edges between n1 and n2, an empty collection if there is no Edge between the two nodes.
Throws:
GraphElementNotFoundException - if one of the nodes is not contained in the graph.

getEdgesIterator

Iterator<Edge> getEdgesIterator()
Returns an iterator over the edges of the Graph.

Returns:
an iterator over the edges of the Graph.

isEmpty

boolean isEmpty()
Returns true if the Graph is empty. E.g. the Graph is equal to a Graph which has been cleared.

Returns:
true if the Graph is empty, false otherwise.

getGraphElements

Collection<GraphElement> getGraphElements()
Returns all nodes and all edges contained in this graph.

Returns:
Collection

getNodes

List<Node> getNodes()
Returns all nodes of the graph. The returned list may be unmodifiable and is only valid as long as the graph is not modified.

Returns:
a list containing all the nodes of the graph.

getNodesIterator

Iterator<Node> getNodesIterator()
Returns an iterator over the nodes of the graph. If the graph is empty an empty iterator will be returned. Note that the iterator is not guaranteed to support the Iterator.remove() operation.

Returns:
an iterator containing the nodes of the graph.

getNumberOfDirectedEdges

int getNumberOfDirectedEdges()
Returns the number of directed edges of the Graph.

Returns:
the number of directed edges of the Graph.

getNumberOfEdges

int getNumberOfEdges()
Returns the number of edges of the Graph.

Returns:
the number of edges of the Graph.

getNumberOfNodes

int getNumberOfNodes()
Returns the number of nodes in the Graph.

Returns:
the number of nodes in the Graph.

getNumberOfUndirectedEdges

int getNumberOfUndirectedEdges()
Returns the number of undirected edges in the Graph.

Returns:
the number of undirected edges in the Graph.

isUndirected

boolean isUndirected()
Indicates whether the Graph is undirected. A Graph is undirected if all the edges are undirected.

Returns:
true if the Graph is undirected, false otherwise.

addAttributeConsumer

void addAttributeConsumer(AttributeConsumer attConsumer)
                          throws UnificationException
Adds the given attribute consumer to the list of attribute consumers.

Parameters:
attConsumer - the attribute consumer to add.
Throws:
UnificationException

addEdge

Edge addEdge(Node source,
             Node target,
             boolean directed)
             throws GraphElementNotFoundException
Adds a new Edge to the current Graph. Informs the ListenerManager about the new Edge.

Parameters:
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.
Returns:
the newly generated Edge.
Throws:
GraphElementNotFoundException - if any of the nodes cannot be found in the Graph.

addEdge

Edge addEdge(Node source,
             Node target,
             boolean directed,
             CollectionAttribute col)
             throws GraphElementNotFoundException
Adds a new Edge to the current Graph. Informs the ListenerManager about the new Edge.

Parameters:
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.
Returns:
the newly generated Edge.
Throws:
GraphElementNotFoundException - if any of the nodes cannot be found in the Graph.

createEdge

Edge createEdge(Node source,
                Node target,
                boolean directed,
                CollectionAttribute col)
Creates a new Edge without actually adding it to the Graph.

Parameters:
source - source-node
target - target-node
directed - shall the new edge be directed?
col - attributes for the new edge
Returns:
the newly created edge

addEdgeCopy

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. Informs the ListenerManager about the newly added Edge. Also informs the ListenerManager about the copy of the attributes added to the Edge.

Parameters:
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.
Returns:
DOCUMENT ME!

addGraph

void addGraph(Graph g)
Adds a 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.

Parameters:
g - the Graph to be added.

addNode

Node addNode()
Adds a new Node to the Graph. Informs the ListenerManager about the new Node.

Returns:
the new Node.

addNode

Node addNode(CollectionAttribute col)
Adds a new node to the graph. Informs the ListenerManager about the new node.

Parameters:
col - the CollectionAttribute the node is initialized with.
Returns:
the new node.

createNode

Node createNode(CollectionAttribute col)
Creates a new node using the given attribute-object without actually adding the created Node to the graph.

Parameters:
col - attributes for the new node
Returns:
newly created Node

addNodeCopy

Node addNodeCopy(Node node)
Adds a copy of the specified 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.

Parameters:
node - the Node which to copy and to add.
Returns:
DOCUMENT ME!

clear

void clear()
Deletes the current Graph by resetting all its attributes. The Graph is then equal to a newly generated Graph.


containsEdge

boolean containsEdge(Edge e)
Returns true, if the Graph contains the specified Edge, false otherwise.

Parameters:
e - the Edge to seach for
Returns:
true, if the Graph contains the specified Edge, false otherwise.

containsNode

boolean containsNode(Node n)
Returns true, if the Graph contains the specified Node, false otherwise.

Parameters:
n - the Node to search for.
Returns:
true, if the Graph contains the Node n, false otherwise.

deleteEdge

void deleteEdge(Edge e)
                throws GraphElementNotFoundException
Deletes Edge e from the current Graph. Informs the ListenerManager about the deletion.

Parameters:
e - the Edge to delete.
Throws:
GraphElementNotFoundException - if the Edge to delete cannot be found in the Graph.

deleteNode

void deleteNode(Node n)
                throws GraphElementNotFoundException
Deletes the Node n. All in- and out-going edges will be deleted. Informs the ListenerManager about the deletion of the Node and the concerned edges.

Parameters:
n - the Node to delete.
Throws:
GraphElementNotFoundException - if the Node to delete cannot be found in the Graph.

removeAttributeConsumer

boolean removeAttributeConsumer(AttributeConsumer attConsumer)
Returns true, if the given attribute consumer was in the list of attribute consumers and could be removed.

Returns:
true, if the given attribute consumer was in the list of attribute consumers and could be removed.


Generated at 2012-05-30 11:00:36 PM CEST