org.molwind.graph
Class DefaultEntityGraph

java.lang.Object
  extended by org.molwind.graph.DefaultEntityGraph
All Implemented Interfaces:
java.lang.Iterable, EntityGraph

public class DefaultEntityGraph
extends java.lang.Object
implements EntityGraph

DefaultEntityGraph implements an EntityGraph using the JUNG graph lib.

Version:
1.0
Author:
Oliver Karch

Constructor Summary
DefaultEntityGraph()
          Creates a new (empty) graph of entities.
 
Method Summary
 void addEdge(java.lang.String vertexId1, java.lang.String vertexId2, Relationship relation, int weight)
          Adds a relationship edge between vertex vertexId1 and vertex vertexId2.
 void addEntity(java.lang.String vertexId, WorldEntity entity)
          Adds an entity i.e.
 void analyze(EntityGraphAnalyzer analyzer)
          Analyzes the entity graph using the given analysis strategy.
 void devideLayers()
          Devides the graph into Layers
 WorldEntity findEntity(java.lang.String vertexId)
          Finds the given vertex id.
 edu.uci.ics.jung.graph.SparseGraph<EntityVertex,EntityEdge> getGraph()
          Get the Graph value.
 EntityVertex[] getLayer(int layer)
          Get all vertices for the given layer
 int getLayerCount()
          Gives the count of Layers for the allocation levels
 java.util.Iterator iterator()
          Returns an iterator over a set of elements.
 void setGraph(edu.uci.ics.jung.graph.SparseGraph newGraph)
          Set the Graph value.
 java.lang.String toString()
          Writes a graph ml representation of this graph
 void viewGraph(int size)
          Visualizes the Graph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultEntityGraph

public DefaultEntityGraph()
Creates a new (empty) graph of entities.

Method Detail

getGraph

public edu.uci.ics.jung.graph.SparseGraph<EntityVertex,EntityEdge> getGraph()
Get the Graph value.

Returns:
the Graph value.

setGraph

public void setGraph(edu.uci.ics.jung.graph.SparseGraph newGraph)
Set the Graph value.

Parameters:
newGraph - The new Graph value.

addEntity

public void addEntity(java.lang.String vertexId,
                      WorldEntity entity)
Adds an entity i.e. vertex to graph. If the vertex id is existing already the vertex is replaced.

Specified by:
addEntity in interface EntityGraph
Parameters:
vertexId - the vertex id
entity - the entity to add

findEntity

public WorldEntity findEntity(java.lang.String vertexId)
Finds the given vertex id.

Specified by:
findEntity in interface EntityGraph
Parameters:
vertexId - the vertex id
Returns:
the entity if it was found, null otherwise

addEdge

public void addEdge(java.lang.String vertexId1,
                    java.lang.String vertexId2,
                    Relationship relation,
                    int weight)
Adds a relationship edge between vertex vertexId1 and vertex vertexId2. For any non-existing vertex a new vertex is created.

Specified by:
addEdge in interface EntityGraph
Parameters:
vertexId1 - the first vertex id
vertexId2 - the second vertex id
relation - the relationship represented by the edge

analyze

public void analyze(EntityGraphAnalyzer analyzer)
Analyzes the entity graph using the given analysis strategy.

Specified by:
analyze in interface EntityGraph
Parameters:
analyzer - the analysis strategy

getLayerCount

public int getLayerCount()
Gives the count of Layers for the allocation levels

Returns:
layer count

getLayer

public EntityVertex[] getLayer(int layer)
Get all vertices for the given layer

Parameters:
the - layer number
Returns:
an array with the vertices belonging to the layer

devideLayers

public void devideLayers()
Devides the graph into Layers


iterator

public java.util.Iterator iterator()
Returns an iterator over a set of elements.

Specified by:
iterator in interface java.lang.Iterable
Returns:
an Iterator

toString

public java.lang.String toString()
Writes a graph ml representation of this graph

Overrides:
toString in class java.lang.Object
Returns:
a human readable string

viewGraph

public void viewGraph(int size)
Visualizes the Graph

Parameters:
the - size of the Frame


Copyright © 2008-2010. All Rights Reserved.