GraphLab Project

graphlab.graph.graph
Class GraphControlGrid

java.lang.Object
  extended by graphlab.graph.graph.GraphControlGrid
All Implemented Interfaces:
GraphModelListener

public class GraphControlGrid
extends java.lang.Object
implements GraphModelListener

This class puts graph elements in a grid (for example in a 10*10 grid) so that searching for the nearest element to a point of graph performs faster, larger grid will have faster searches, it does not guaranteed to have a fast search at every situation, but overally in a grid of size n (a n*n rectangle) the search for the vertex on the given point will finish in V(G)/(n*n) steps. for an edge it will be some thing near E(G)/(n*n) (it can be larger up to E(G)/(n) because edges aare lines and can fill more than one cell in the grid.) In the worst case the search for the vertex will be run in V(G) steps and for the Edge in E(g) steps.

Adding and removing element to/from graph has some cost here. but the cost will not appear until a search for an element in graph is performed. the cost is small (in average case) when the graph bounds doesn't become larger, but when it become larger the cost is V(G) (or E(G))

Author:
Azin Azadi

Constructor Summary
GraphControlGrid(GraphModel g)
           
 
Method Summary
 void edgeAdded(EdgeModel e)
           
 void edgeRemoved(EdgeModel e)
           
 void graphCleared()
           
 Pair mindiste(GraphModel g, GraphPoint p)
           
 Pair<VertexModel,java.lang.Double> mindistv(GraphPoint p)
           
 void repaintGraph()
           
 void vertexAdded(VertexModel v)
           
 void vertexRemoved(VertexModel v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphControlGrid

public GraphControlGrid(GraphModel g)
Method Detail

mindiste

public Pair mindiste(GraphModel g,
                     GraphPoint p)

mindistv

public Pair<VertexModel,java.lang.Double> mindistv(GraphPoint p)

vertexAdded

public void vertexAdded(VertexModel v)
Specified by:
vertexAdded in interface GraphModelListener

vertexRemoved

public void vertexRemoved(VertexModel v)
Specified by:
vertexRemoved in interface GraphModelListener

edgeAdded

public void edgeAdded(EdgeModel e)
Specified by:
edgeAdded in interface GraphModelListener

edgeRemoved

public void edgeRemoved(EdgeModel e)
Specified by:
edgeRemoved in interface GraphModelListener

graphCleared

public void graphCleared()
Specified by:
graphCleared in interface GraphModelListener

repaintGraph

public void repaintGraph()
Specified by:
repaintGraph in interface GraphModelListener

GraphLab Project