net.sourceforge.combean.graph.prop.statics
Class ConstructableNumberedGraphBuilder

Package class diagram package ConstructableNumberedGraphBuilder
java.lang.Object
  extended by net.sourceforge.combean.graph.prop.statics.ConstructableNumberedGraphBuilder

public class ConstructableNumberedGraphBuilder
extends Object

Convenience class which supports constructing a graph where the nodes and edges are referenced through integers.


Constructor Summary
ConstructableNumberedGraphBuilder(ConstructableNumberedGraphProp g)
          Constructor
 
Method Summary
 int addEdge(int fromNodeNum, int toNodeNum)
          Add an edge
 int addEdge(int fromNodeNum, int toNodeNum, double doubleVal)
          Add an edge and set its weight in an edge map
 void addEdges(int[][] edges)
          Add multiple edges.
 void addEdgesWithWeights(int[][] edgesWithWeights)
          Add multiple edges and set their (integer) weights.
 int addNode()
          Add a new node
 int addNode(double doubleVal)
          Add a new node and set its weight
 int addNodes(int numNodesToAdd)
          Add several nodes simulatenously
 int addNodesWithWeights(int numNodesToAdd, double[] nodeWeights)
          Add several nodes simultaneously and fill a NodeMap
 void addPathEdges(int fromNodeNum, int toNodeNum)
          Add edges forming a path on consecutive nodes, i.e., edges (fromNodeNum, fromNodeNum+1), (fromNodeNum+1, fromNodeNum+2), ..., (toNodeNum-1, toNodeNum)
 void addPathEdgesWithWeights(int fromNodeNum, int toNodeNum, double[] edgeWeights)
          Add edges forming a path on consecutive nodes, i.e., edges (fromNodeNum, fromNodeNum+1), (fromNodeNum+1, fromNodeNum+2), ..., (toNodeNum-1, toNodeNum) with edge weights
 void fillDoubleEdgeMap(DoubleEdgeMap mapToFill, double[] edgeWeights)
          Fill a DoubleEdgeMap with double values for all edges in the graph.
 void fillDoubleNodeMap(DoubleNodeMap mapToFill, double[] nodeWeights)
          Fill a DoubleNodeMap with double values for all nodes in the graph.
 void fillEdgeMap(EdgeMap<Double> mapToFill, double[] edgeWeights)
          Fill an EdgeMap with double values for all edges in the graph.
 void setEdgeMap(EdgeMap<Double> edgeMap)
          When creating edges, it is possible to store edge weights.
 void setNodeMap(NodeMap<Double> nodeMap)
          When creating nodes, it is possible to store node weights.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstructableNumberedGraphBuilder

public ConstructableNumberedGraphBuilder(ConstructableNumberedGraphProp g)
Constructor

Parameters:
g - the graph which shall be built
Method Detail

setNodeMap

public void setNodeMap(NodeMap<Double> nodeMap)
When creating nodes, it is possible to store node weights. If this feature shall be used, a NodeMap has to be set before using this method.

Parameters:
nodeMap - NodeMap to be used for node weights

setEdgeMap

public void setEdgeMap(EdgeMap<Double> edgeMap)
When creating edges, it is possible to store edge weights. If this feature shall be used, an EdgeMap has to be set before using this method.

Parameters:
edgeMap - EdgeMap to be used for edge weights

addNode

public int addNode()
Add a new node

Returns:
the integer identifier of the node

addNode

public int addNode(double doubleVal)
Add a new node and set its weight

Parameters:
doubleVal - the weight of the node
Returns:
the integer identifier of the node

addNodes

public int addNodes(int numNodesToAdd)
Add several nodes simulatenously

Parameters:
numNodesToAdd - the number of nodes be added
Returns:
the integer identifier of the last node which was added (the other nodes will have consecutive identifiers starting from identifier of last node - numNodesToAdd + 1

addNodesWithWeights

public int addNodesWithWeights(int numNodesToAdd,
                               double[] nodeWeights)
Add several nodes simultaneously and fill a NodeMap

Parameters:
numNodesToAdd - the number of nodes be added
nodeWeights - the weights of the nodes to be added
Returns:
the integer identifier of the last node which was added (the other nodes will have consecutive identifiers starting from identifier of last node - numNodesToAdd + 1

addEdge

public int addEdge(int fromNodeNum,
                   int toNodeNum)
Add an edge

Parameters:
fromNodeNum - the integer identifier of the source node
toNodeNum - the integer identifier of the target node
Returns:
the integer identifier of the new edge

addEdge

public int addEdge(int fromNodeNum,
                   int toNodeNum,
                   double doubleVal)
Add an edge and set its weight in an edge map

Parameters:
fromNodeNum - the integer identifier of the source node
toNodeNum - the integer identifier of the target node
doubleVal - the value to be assigned to the new edge
Returns:
the integer identifier of the new edge

addEdges

public void addEdges(int[][] edges)
Add multiple edges.

Parameters:
edges - an array defining the edges and their weights. edgesWithWeights[i] contains the source and the target node at the indices 0 and 1.

addEdgesWithWeights

public void addEdgesWithWeights(int[][] edgesWithWeights)
Add multiple edges and set their (integer) weights.

Parameters:
edgesWithWeights - an array defining the edges and their weights. edgesWithWeights[i] contains the source and the target node at the indices 0 and 1, as well as the edge weight at index 2.

addPathEdges

public void addPathEdges(int fromNodeNum,
                         int toNodeNum)
Add edges forming a path on consecutive nodes, i.e., edges (fromNodeNum, fromNodeNum+1), (fromNodeNum+1, fromNodeNum+2), ..., (toNodeNum-1, toNodeNum)

Parameters:
fromNodeNum - the index of the first node in the path
toNodeNum - the index of the last node in the path

addPathEdgesWithWeights

public void addPathEdgesWithWeights(int fromNodeNum,
                                    int toNodeNum,
                                    double[] edgeWeights)
Add edges forming a path on consecutive nodes, i.e., edges (fromNodeNum, fromNodeNum+1), (fromNodeNum+1, fromNodeNum+2), ..., (toNodeNum-1, toNodeNum) with edge weights

Parameters:
fromNodeNum - the index of the first node in the path
toNodeNum - the index of the last node in the path
edgeWeights - the weights of the edges (array must contain toNodeNum - fromNodeNum elements)

fillEdgeMap

public void fillEdgeMap(EdgeMap<Double> mapToFill,
                        double[] edgeWeights)
Fill an EdgeMap with double values for all edges in the graph.

Parameters:
mapToFill - the EdgeMap to be filled
edgeWeights - an array containing the weights to store in the map

fillDoubleEdgeMap

public void fillDoubleEdgeMap(DoubleEdgeMap mapToFill,
                              double[] edgeWeights)
Fill a DoubleEdgeMap with double values for all edges in the graph.

Parameters:
mapToFill - the DoubleEdgeMap to be filled
edgeWeights - an array containing the weights to store in the map

fillDoubleNodeMap

public void fillDoubleNodeMap(DoubleNodeMap mapToFill,
                              double[] nodeWeights)
Fill a DoubleNodeMap with double values for all nodes in the graph.

Parameters:
mapToFill - the DoubleNodeMap to be filled
nodeWeights - an array containing the weights to store in the map