GraphLab Project

graphlab.graph.graph
Class GraphModel

java.lang.Object
  extended by graphlab.library.BaseGraph<VertexType,EdgeType>
      extended by graphlab.library.ListGraph<VertexModel,EdgeModel>
          extended by graphlab.graph.graph.GraphModel
All Implemented Interfaces:
StorableOnExit, java.lang.Iterable<VertexModel>

public class GraphModel
extends ListGraph<VertexModel,EdgeModel>
implements StorableOnExit

Author:
Azin Azadi,roozbeh ebrahimi

Field Summary
static java.awt.Color[] color
           
 boolean isEdgesCurved
          It is true if the edges of this graph are curves (not line), This will be applied to all edges of graph
static boolean showEdgeWeights
           
static boolean vertexLabelsEnabled
           
 
Fields inherited from class graphlab.library.BaseGraph
isSubgraph, lastSubgraphIndex, subgraphIndex, superGraph
 
Fields inherited from interface graphlab.platform.preferences.lastsettings.StorableOnExit
SETTINGS
 
Constructor Summary
GraphModel()
          generates an undirected graph
GraphModel(boolean isdirected)
           
 
Method Summary
static void addGlobalUserDefinedAttribute(java.lang.String name, java.lang.Object defaultvalue)
          sets and stores a global user defined attribute for the graph.
 void addGraphListener(GraphModelListener listener)
           
 void addSubGraph(GraphModel graph, java.awt.Rectangle _rect)
          adds graph to this graph and place it in the given rectangle
 void clear()
          Clears the graph.
 GraphModel createEmptyGraph()
          Returns a new instance of an empty graph of the current graph type.
 java.awt.geom.Rectangle2D.Double getAbsBounds()
           
static java.awt.Color getColor(java.lang.Integer i)
          in GraphLab all Colors that assign to Vertices/Edges are in values, so they can not directly shown with distinct colors, this method gived the standard GraphLab solution to this which assigns unique colors to 1..20 and if i>20, It will regards the i itself as the color (new Color(i)) regarding the fact that normally in GraphTheory Colors have small values.
 EdgeModel getEdge(VertexModel v1, VertexModel v2)
           
 int getEdgesCount()
           
 java.awt.Font getFont()
           
 java.lang.String getLabel()
           
<t> t
getUserDefinedAttribute(java.lang.String name)
          returns the specified user defined attribute, or null if it does not exists.
 java.util.HashMap<java.lang.String,java.lang.Object> getUserDefinedAttributes()
           
 VertexModel[] getVertexArray()
          Returns array of vertices upcasted to BaseVertex.
 ArrayX<java.lang.String> getZoom()
           
 java.awt.geom.Rectangle2D.Double getZoomedBounds()
           
 double getZoomFactor()
           
 void insertEdge(EdgeModel newedge)
          adds new edge only if it doesn't exist in graph
 void insertEdges(EdgeModel[] edges)
           
 void insertEdges(java.lang.Iterable<EdgeModel> edgeModels)
           
 void insertVertex(VertexModel newVertex)
          same to insertVertex
 void insertVertices(java.util.Collection<VertexModel> vertices)
           
 void insertVertices(VertexModel[] vertices)
           
 boolean isDrawEdgeLabels()
           
 boolean isDrawVertexLabels()
           
 boolean isEdgesCurved()
           
 boolean isShowChangesOnView()
           
 void removeAllEdges(VertexModel source, VertexModel target)
          Removes all edges between two vertices.
 void removeEdge(EdgeModel edge)
          Removes an edge from the graph.
static void removeGlobalUserDefinedAttribute(java.lang.String name)
           
 void removeGraphListener(GraphModelListener listener)
           
 void removeUserDefinedAttribute(java.lang.String name)
          removes the given attribute from the list of user defined attributes
 void removeVertex(VertexModel v)
          Removes a vertex and all it's connected edges.
 void setDrawEdgeLabels(boolean drawEdgeLabels)
           
 void setDrawVertexLabels(boolean drawVertexLabels)
           
 void setFont(java.awt.Font font)
           
 void setIsEdgesCurved(boolean isCurve)
          set the edges of this graph to be curves or lines
 void setLabel(java.lang.String s)
           
 void setShowChangesOnView(boolean showChangesOnView)
          determines whether show changes in model to view, for example when an algorithm changes the color of a vertex in VertexModel(BaseVertex) should a color be assigned in GUI to it or not?
 void setUserDefinedAttribute(java.lang.String name, java.lang.Object value)
          sets and stores a user defined attribute for the graph.
 void setZoom(ArrayX<java.lang.String> zoom)
           
 void setZoom(double zoomFactor)
           
 void zoomIn()
           
 void zoomOut()
           
 
Methods inherited from class graphlab.library.ListGraph
checkVertex, containsVertex, copy, dump, edgeIterator, edgeIterator, getAdjacencyMatrix, getAVertex, getEdgeArray, getEdges, getInDegree, getOutDegree, getVerticesCount, isDirected, isEdge, iterator, lightEdgeIterator, lightEdgeIterator, setDirected, setId
 
Methods inherited from class graphlab.library.BaseGraph
edges, getDegree, getEdges, getId, getNeighbors, getNewSubgraphIndex, registerSubgraph, setSubGraphIndex, vertices
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

showEdgeWeights

public static boolean showEdgeWeights

vertexLabelsEnabled

public static boolean vertexLabelsEnabled

color

public static final java.awt.Color[] color

isEdgesCurved

public boolean isEdgesCurved
It is true if the edges of this graph are curves (not line), This will be applied to all edges of graph

Constructor Detail

GraphModel

public GraphModel()
generates an undirected graph


GraphModel

public GraphModel(boolean isdirected)
Method Detail

createEmptyGraph

public GraphModel createEmptyGraph()
Description copied from class: BaseGraph
Returns a new instance of an empty graph of the current graph type.

Overrides:
createEmptyGraph in class ListGraph<VertexModel,EdgeModel>
Returns:
A new instance of an empty graph of the current graph type.

setUserDefinedAttribute

public void setUserDefinedAttribute(java.lang.String name,
                                    java.lang.Object value)
sets and stores a user defined attribute for the graph. here you can put any attribute you like that are not available in the standard attributes. your attributes will be editable in property editor part of GUI.

Parameters:
name -
value -

getUserDefinedAttribute

public <t> t getUserDefinedAttribute(java.lang.String name)
returns the specified user defined attribute, or null if it does not exists.

Parameters:
name -
Returns:

removeUserDefinedAttribute

public void removeUserDefinedAttribute(java.lang.String name)
removes the given attribute from the list of user defined attributes

Parameters:
name -

getUserDefinedAttributes

public java.util.HashMap<java.lang.String,java.lang.Object> getUserDefinedAttributes()
Returns:
a HashMap containing all user defined attributes.

addGlobalUserDefinedAttribute

public static void addGlobalUserDefinedAttribute(java.lang.String name,
                                                 java.lang.Object defaultvalue)
sets and stores a global user defined attribute for the graph. this attributes will be added to each graph on constructing time using setUserDefinedAttribute method.

note that this method only affects the afterward created graphs, and current graph will not affected by this method.


removeGlobalUserDefinedAttribute

public static void removeGlobalUserDefinedAttribute(java.lang.String name)
See Also:
addGlobalUserDefinedAttribute(java.lang.String, java.lang.Object)

setShowChangesOnView

public void setShowChangesOnView(boolean showChangesOnView)
determines whether show changes in model to view, for example when an algorithm changes the color of a vertex in VertexModel(BaseVertex) should a color be assigned in GUI to it or not?

Parameters:
showChangesOnView -

isShowChangesOnView

public boolean isShowChangesOnView()

insertVertex

public void insertVertex(VertexModel newVertex)
same to insertVertex

Overrides:
insertVertex in class ListGraph<VertexModel,EdgeModel>
Parameters:
newVertex - The new vertex to be inserted.

insertVertices

public void insertVertices(java.util.Collection<VertexModel> vertices)

removeAllEdges

public void removeAllEdges(VertexModel source,
                           VertexModel target)
                    throws InvalidVertexException
Description copied from class: BaseGraph
Removes all edges between two vertices.

Overrides:
removeAllEdges in class ListGraph<VertexModel,EdgeModel>
Parameters:
source - Index of the edges' start point.
target - Index of the edges' end point.
Throws:
InvalidVertexException - Thrown when two supplied indexes of vertices are invalid.

removeEdge

public void removeEdge(EdgeModel edge)
                throws InvalidEdgeException
Description copied from class: BaseGraph
Removes an edge from the graph.

Overrides:
removeEdge in class ListGraph<VertexModel,EdgeModel>
Parameters:
edge - Edge to be removed.
Throws:
InvalidEdgeException - If edge is an invalid edge object.

removeVertex

public void removeVertex(VertexModel v)
                  throws InvalidVertexException
Description copied from class: BaseGraph
Removes a vertex and all it's connected edges.

Overrides:
removeVertex in class ListGraph<VertexModel,EdgeModel>
Throws:
InvalidVertexException

clear

public void clear()
Description copied from class: BaseGraph
Clears the graph.

Overrides:
clear in class ListGraph<VertexModel,EdgeModel>

getEdge

public EdgeModel getEdge(VertexModel v1,
                         VertexModel v2)

insertEdge

public void insertEdge(EdgeModel newedge)
adds new edge only if it doesn't exist in graph

Overrides:
insertEdge in class ListGraph<VertexModel,EdgeModel>
Parameters:
newedge -

getEdgesCount

public int getEdgesCount()
Overrides:
getEdgesCount in class ListGraph<VertexModel,EdgeModel>

addGraphListener

public void addGraphListener(GraphModelListener listener)

removeGraphListener

public void removeGraphListener(GraphModelListener listener)

getAbsBounds

public java.awt.geom.Rectangle2D.Double getAbsBounds()
Returns:
the smallest rectangle that fits arround graph without considering the ZOOM

getZoomedBounds

public java.awt.geom.Rectangle2D.Double getZoomedBounds()
Returns:
the smallest rectangle that fits arround graph with considering zoom

getZoomFactor

public double getZoomFactor()

getZoom

public ArrayX<java.lang.String> getZoom()

setZoom

public void setZoom(ArrayX<java.lang.String> zoom)

zoomIn

public void zoomIn()

zoomOut

public void zoomOut()

setZoom

public void setZoom(double zoomFactor)

setLabel

public void setLabel(java.lang.String s)

getLabel

public java.lang.String getLabel()

insertEdges

public void insertEdges(java.lang.Iterable<EdgeModel> edgeModels)

addSubGraph

public void addSubGraph(GraphModel graph,
                        java.awt.Rectangle _rect)
adds graph to this graph and place it in the given rectangle

Parameters:
graph -
_rect -

getColor

public static java.awt.Color getColor(java.lang.Integer i)
in GraphLab all Colors that assign to Vertices/Edges are in values, so they can not directly shown with distinct colors, this method gived the standard GraphLab solution to this which assigns unique colors to 1..20 and if i>20, It will regards the i itself as the color (new Color(i)) regarding the fact that normally in GraphTheory Colors have small values.

Returns:
an RGB color which is representing the given integer Color in GraphLab

getFont

public java.awt.Font getFont()

setFont

public void setFont(java.awt.Font font)

isDrawEdgeLabels

public boolean isDrawEdgeLabels()

setDrawEdgeLabels

public void setDrawEdgeLabels(boolean drawEdgeLabels)

isDrawVertexLabels

public boolean isDrawVertexLabels()

setDrawVertexLabels

public void setDrawVertexLabels(boolean drawVertexLabels)

isEdgesCurved

public boolean isEdgesCurved()
Returns:
true if the edges of this graph are curves (not lines), This is about all edges of graph

setIsEdgesCurved

public void setIsEdgesCurved(boolean isCurve)
set the edges of this graph to be curves or lines

Parameters:
isCurve -

insertVertices

public void insertVertices(VertexModel[] vertices)

insertEdges

public void insertEdges(EdgeModel[] edges)

getVertexArray

public VertexModel[] getVertexArray()
Description copied from class: BaseGraph
Returns array of vertices upcasted to BaseVertex.

Overrides:
getVertexArray in class ListGraph<VertexModel,EdgeModel>
Returns:
Array of vertices upcasted to BaseVertex.

GraphLab Project