com.tensegrity.graph.model
Class GraphManipulation

java.lang.Object
  extended bycom.tensegrity.graph.model.GraphManipulation

public final class GraphManipulation
extends java.lang.Object

This class has code that manipulates different sorts of graphs that are used frequently or that are some sort of standard graphs. These graphs are used for debugging and testing graph algorithms and might also be of interest for api users or even final-customers.

Version:
$Id: GraphManipulation.java,v 1.23 2005/04/04 07:22:54 MichaelKegel Exp $
Author:
S. Rutz

Method Summary
static void addEdges(Graph graph, int n)
          Adds n edges to the graph.
static void addNodes(Graph graph, int n)
          Adds n nodes to the graph.
static void deleteRandomEdges(Graph graph, int n)
          Deletes n random edges from the graph.
static void deleteRandomNodes(Graph graph, int n)
          Deletes n random nodes from the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deleteRandomEdges

public static final void deleteRandomEdges(Graph graph,
                                           int n)
                                    throws GraphException
Deletes n random edges from the graph. If the graph does not have enough edges to remove further edges from it, the method returns.

Parameters:
graph - the graph to remove edges from.
n - the number of edges to remove.
Throws:
GraphException - thrown if something goes wrong during the edge removal.

deleteRandomNodes

public static final void deleteRandomNodes(Graph graph,
                                           int n)
                                    throws GraphException
Deletes n random nodes from the graph. If the graph does not have enough nodes to remove further nodes from it, the method returns.

Parameters:
graph - the graph to remove nodes from.
n - the number of nodes to remove.
Throws:
GraphException - thrown if something goes wrong during the node removal.

addEdges

public static final void addEdges(Graph graph,
                                  int n)
                           throws GraphException
Adds n edges to the graph. The graph should have at least 2 nodes. Nodes are selected pseudo-randomly. This method uses to lists.
One for source-, one for target nodes. Source nodes are picked randomly, target nodes are looked up from the arraylist. If no such target node is found, this method returns and quits adding edges.

Parameters:
graph - the graph to add edges to.
n - the number of edges to add.
Throws:
GraphException - thrown if something goes wrong during the edge addition.

addNodes

public static final void addNodes(Graph graph,
                                  int n)
                           throws GraphException
Adds n nodes to the graph.

Parameters:
graph - the graph to add nodes to.
n - the number of nodes to add.
Throws:
GraphException - thrown if something goes wrong during the node addition.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.