de.fhstralsund.vinets.structure
Interface Graph

All Superinterfaces:
java.lang.Cloneable, NetElement, java.io.Serializable
All Known Subinterfaces:
Block
All Known Implementing Classes:
AbstractGraph, GraphAdapter, SimpleGraph

public interface Graph
extends NetElement

An object models a Graph or HyperGraph. In a hierarchical Graph, the interface reveals the view on the inner contents of a Block as a container of Nodes and Links. The interface includes also factory methods to create the elements of a Graph. The intend is to ensure compatibility between the concrete classes of all objects belonging to the same Graph.


Method Summary
 java.lang.Object clone()
          Delivers a deep copy of this Graph.
 int countEdges()
          Returns the number of Links in this Graph.
 int countNodes()
          Returns the number of Nodes in this Graph.
 Link createEdge(Node start, Node end)
          Constructs and returns a new Edge of the appropriate type.
 Link createEdge(Node start, Node end, boolean directed)
          Constructs and returns a new directed or undirected Edge.
 Link createEdge(Node start, Node end, boolean directed, java.lang.Object data)
          Constructs and returns a new directed or undirected Edge with two end vertices.
 Node createNode()
          Constructs and returns a new Node.
 Node createNode(java.lang.String name)
          Constructs and returns a new Node.
 Node createNode(java.lang.String name, java.lang.Object data)
          Constructs and returns a new Node.
 java.util.Iterator edges()
          Delivers an Iterator over all Links in this Graph.
 java.util.Set edgeSet()
          Delivers the Set of Links in this Graph.
 GraphType getGraphType()
          Returns the Type of this Graph.
 boolean isDirected()
          All Links of a directed Graph are directed Edges between two Nodes.
 boolean isHyperGraph()
          A HyperGraph may contain HyperEdges that have more than two end vertices.
 boolean isMixed()
          A mixed Graph may contain some undirected and some directed Edges, but all Links have exactly two end Nodes.
 boolean isUndirected()
          All Links of an undirected Graph are undirected Edges between two Nodes.
 java.util.Iterator nodes()
          Delivers an Iterator over all Nodes in this Graph.
 java.util.Set nodeSet()
          Delivers the Set of Nodes in this Graph.
 boolean remove(NetElement n)
          Removes a NetElement from this Graph.
 
Methods inherited from interface de.fhstralsund.vinets.structure.NetElement
clearLabels, containsLabel, getBooleanLabel, getData, getDoubleLabel, getGeometry, getHost, getID, getIntLabel, getLabel, getLabelKeySet, getName, getOriginal, getRepresentation, removeLabel, setBooleanLabel, setData, setDoubleLabel, setGeometry, setIntLabel, setLabel, setName, setRepresentation
 

Method Detail

isDirected

boolean isDirected()
All Links of a directed Graph are directed Edges between two Nodes.

Returns:
true if the Graph is directed.

isUndirected

boolean isUndirected()
All Links of an undirected Graph are undirected Edges between two Nodes.

Returns:
true if the Graph is undirected.

isMixed

boolean isMixed()
A mixed Graph may contain some undirected and some directed Edges, but all Links have exactly two end Nodes.

Returns:
true if the Graph is a mixed Graph.

isHyperGraph

boolean isHyperGraph()
A HyperGraph may contain HyperEdges that have more than two end vertices. A HyperGraph is neither directed nor undirected.

Returns:
true if the Graph is a HyperGraph.

countNodes

int countNodes()
Returns the number of Nodes in this Graph.

Returns:
the number of Nodes.

countEdges

int countEdges()
Returns the number of Links in this Graph.

Returns:
the number of all Links (directed/undirected/hyperedges).

nodes

java.util.Iterator nodes()
Delivers an Iterator over all Nodes in this Graph.

Returns:
an Iterator to traverse all Nodes of this Graph.

nodeSet

java.util.Set nodeSet()
Delivers the Set of Nodes in this Graph.

Returns:
a Set which contains all Nodes of this Graph.

edges

java.util.Iterator edges()
Delivers an Iterator over all Links in this Graph.

Returns:
an Iterator to traverse all Links of this Graph.

edgeSet

java.util.Set edgeSet()
Delivers the Set of Links in this Graph.

Returns:
a Set which contains all Links of this Graph.

createNode

Node createNode(java.lang.String name,
                java.lang.Object data)
Constructs and returns a new Node.

Parameters:
name - a name used to identify this Node for the user.
data - external data of any kind that an application may need.
Returns:
a new Node instance.

createNode

Node createNode(java.lang.String name)
Constructs and returns a new Node.

Parameters:
name - a name used to identify this Node for the user.
Returns:
a new Node instance.

createNode

Node createNode()
Constructs and returns a new Node.

Returns:
a new Node instance.

createEdge

Link createEdge(Node start,
                Node end,
                boolean directed,
                java.lang.Object data)
Constructs and returns a new directed or undirected Edge with two end vertices.

Parameters:
start - the source Node.
end - the target Node.
directed - true if the Edge is directed.
data - external data of any kind that an application may need
Returns:
a new Edge instance
Throws:
java.lang.IllegalArgumentException - if start or end have a wrong host or the edge type is not feasible for this Graph

createEdge

Link createEdge(Node start,
                Node end,
                boolean directed)
Constructs and returns a new directed or undirected Edge. The source and target Nodes should have the same host.

Parameters:
start - source Node
end - target Node
directed - true if the Edge is directed, false otherwise.
Returns:
a new Edge instance
Throws:
java.lang.IllegalArgumentException - if start or end have a wrong host or the edge type is not feasible for this Graph

createEdge

Link createEdge(Node start,
                Node end)
Constructs and returns a new Edge of the appropriate type. The source and target Nodes should have the same host.

Parameters:
start - source Node
end - target Node
Returns:
a new Edge instance
Throws:
java.lang.IllegalArgumentException - if start or end have a wrong host

remove

boolean remove(NetElement n)
Removes a NetElement from this Graph. The method should be implemented for all types of Nodes and Links of the concrete Graph class.

Parameters:
n - the NetElement to be removed.
Returns:
true if n was removed succesfully, false if it was not contained in this Graph.
Throws:
java.lang.IllegalArgumentException - if n has a type that cannot be an element of this Graph

clone

java.lang.Object clone()
Delivers a deep copy of this Graph.


getGraphType

GraphType getGraphType()
Returns the Type of this Graph.

Returns:
the Type of this Graph