de.aitools.iv.graphdrawing.datastructures.graph
Class UndirectedGraph

java.lang.Object
  extended by de.aitools.iv.graphdrawing.datastructures.graph.UndirectedGraph
All Implemented Interfaces:
Graph, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class UndirectedGraph
extends java.lang.Object
implements Graph, java.lang.Cloneable, java.io.Externalizable

Author:
smze@upb.de
See Also:
Serialized Form

Constructor Summary
UndirectedGraph()
          Constructor
UndirectedGraph(int size)
          Constructor
 
Method Summary
 void addEdge(Edge e)
          adds an edge to the graph.
 void addVertex(Vertex v)
          adds a Vertex to the graph.
 java.lang.Object clone()
           
 double[][] createAdjacencyMatrix(double diagonalValue)
           
 java.util.Iterator edgeIterator()
          returns all edges that point from a vertex to an other vertex
 int getEdgeCount()
           
 UndirectedGraph getSubGraph(int[] vertexIndices)
           
 UndirectedGraph getSubGraph(Vertex newRoot)
          creates a subGraph
 double getSumOfEdgeWeights()
           
 double getSumOfEdgeWeights(double threshold)
           
 double getSumOfEdgeWeights(int[] vertexIndices)
           
 double getSumOfEdgeWeights(int[] vertexIndices, double threshold)
           
 Vertex getVertex(int id)
          Returns the vertex with this id
 int getVertexCount()
           
 java.util.Iterator incidentEdgeIterator(Vertex v)
          returns all incident edges from the given vertex
 void invertEdgeWeights()
           
static void main(java.lang.String[] args)
          main-function for debug
 void normalizeEdgeWeights()
           
 void normalizeEdgeWeights(double maxWeight)
           
 void printStatistics()
           
 void readExternal(java.io.ObjectInput in)
           
 void removeEdge(Edge e)
          remove an edge from the graph (and from both adjacent Vertices) //O(1)
 void removeVertex(Vertex v)
          remove the Vertex and all incident edges from the graph.
 void renumberVertices()
           
 java.lang.String toString()
          toString-method only for debugging
 java.util.Iterator vertexIterator()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UndirectedGraph

public UndirectedGraph()
Constructor


UndirectedGraph

public UndirectedGraph(int size)
Constructor

Parameters:
size - the initial capacity of the vector
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getSubGraph

public UndirectedGraph getSubGraph(Vertex newRoot)
creates a subGraph

Parameters:
newRoot - starting vertex, new root vertex

getSubGraph

public UndirectedGraph getSubGraph(int[] vertexIndices)

renumberVertices

public void renumberVertices()

addVertex

public void addVertex(Vertex v)
adds a Vertex to the graph.

Parameters:
v - the Vertex to be added

vertexIterator

public java.util.Iterator vertexIterator()
Specified by:
vertexIterator in interface Graph
Returns:
an iterator for the vertices that belongs to this graph

getVertexCount

public int getVertexCount()
Specified by:
getVertexCount in interface Graph
Returns:
the number of vertices that belong to this graph

getEdgeCount

public int getEdgeCount()
Specified by:
getEdgeCount in interface Graph

removeVertex

public void removeVertex(Vertex v)
remove the Vertex and all incident edges from the graph. //O(|connected edges|)

Parameters:
v - the Vertex to be removed

getVertex

public Vertex getVertex(int id)
Returns the vertex with this id

Parameters:
id - of the Vertex
Returns:
the Vertex or NULL

addEdge

public void addEdge(Edge e)
adds an edge to the graph. //O(1)

Parameters:
e - the Edge to be added.

removeEdge

public void removeEdge(Edge e)
remove an edge from the graph (and from both adjacent Vertices) //O(1)

Parameters:
e - the Edge to be removed

incidentEdgeIterator

public java.util.Iterator incidentEdgeIterator(Vertex v)
returns all incident edges from the given vertex

Parameters:
v - the connected Vertex

edgeIterator

public java.util.Iterator edgeIterator()
returns all edges that point from a vertex to an other vertex

Specified by:
edgeIterator in interface Graph
Returns:
all edges that point from a vertex to an other vertex

invertEdgeWeights

public void invertEdgeWeights()

normalizeEdgeWeights

public void normalizeEdgeWeights()

normalizeEdgeWeights

public void normalizeEdgeWeights(double maxWeight)

getSumOfEdgeWeights

public double getSumOfEdgeWeights()

getSumOfEdgeWeights

public double getSumOfEdgeWeights(double threshold)
Specified by:
getSumOfEdgeWeights in interface Graph

getSumOfEdgeWeights

public double getSumOfEdgeWeights(int[] vertexIndices)

getSumOfEdgeWeights

public double getSumOfEdgeWeights(int[] vertexIndices,
                                  double threshold)
Specified by:
getSumOfEdgeWeights in interface Graph

createAdjacencyMatrix

public double[][] createAdjacencyMatrix(double diagonalValue)

printStatistics

public void printStatistics()

toString

public java.lang.String toString()
toString-method only for debugging

Overrides:
toString in class java.lang.Object
Returns:
a String that represents this UndirectedGraph

main

public static void main(java.lang.String[] args)
main-function for debug


writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException