de.korelstar.math.graph
Class Graph

java.lang.Object
  extended by de.korelstar.math.graph.Graph

public class Graph
extends java.lang.Object

Mathematical Graph


Constructor Summary
Graph()
          Creates an empty Graph
Graph(java.util.Collection nodes)
          Creates a Graph with some nodes
Graph(java.util.Collection nodes, java.util.Collection edges)
          Creates a Graph with some nodes and edges
 
Method Summary
 void addEdge(Edge e)
          Adds an edge to the graph
 void addNode(Node n)
          Adds a node to the graph
 boolean containsEdge(Node source, Node target)
          Checks, if the graph contains a certain edge
 boolean containsNode(Node n)
          Checks, if the graph contains a certain node
 boolean containsPath(Node source, Node target)
          Checks, if the graph contains a certain path
 java.util.Set getCycles(Node start)
          Get all cycles in the graph, which are on the path from a certain node
 java.util.Set getEdges()
           
 java.util.Set getNodes()
           
 java.util.Set getPredecessors(Node n)
          Gets the set of nodes, which has a transition to the actual node
 java.util.List getSerialization(Node from, Node to)
          Gets a serialization of all Nodes in the range.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Creates an empty Graph


Graph

public Graph(java.util.Collection nodes)
Creates a Graph with some nodes

Parameters:
nodes - Collection of nodes
See Also:
Node

Graph

public Graph(java.util.Collection nodes,
             java.util.Collection edges)
Creates a Graph with some nodes and edges

Parameters:
nodes - Collections of nodes
edges - Collections of edges
See Also:
Node, Edge
Method Detail

getNodes

public java.util.Set getNodes()
Returns:
all nodes in this graph

addNode

public void addNode(Node n)
Adds a node to the graph

Parameters:
n - New node

containsNode

public boolean containsNode(Node n)
Checks, if the graph contains a certain node

Parameters:
n - Node to check

getEdges

public java.util.Set getEdges()
Returns:
all edges in this graph

addEdge

public void addEdge(Edge e)
Adds an edge to the graph

Parameters:
e - New edge

getPredecessors

public java.util.Set getPredecessors(Node n)
Gets the set of nodes, which has a transition to the actual node

Parameters:
n - Successor of the Nodes to find
Returns:
Set of Nodes

containsEdge

public boolean containsEdge(Node source,
                            Node target)
Checks, if the graph contains a certain edge

Parameters:
source - Source Node of the Edge
target - Target Node of the Edge

containsPath

public boolean containsPath(Node source,
                            Node target)
Checks, if the graph contains a certain path

Parameters:
source - Source Node of the Edge
target - Target Node of the Edge

getCycles

public java.util.Set getCycles(Node start)
Get all cycles in the graph, which are on the path from a certain node

Parameters:
start - Node, where the detection algorithm starts
Returns:
Set of Cycles

getSerialization

public java.util.List getSerialization(Node from,
                                       Node to)
Gets a serialization of all Nodes in the range. The Graph must not contain any cycles in this range!

Parameters:
from - Start with this Node
to - Process only until this Node is reached

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object