org.grinvin.graphs

Class DefaultGraphBundle

Implemented Interfaces:
GraphBundle, GraphBundleView
Known Direct Subclasses:
GraphBundleWithModels

public class DefaultGraphBundle
extends java.lang.Object
implements GraphBundle

Default implementation of GraphBundle. Uses DefaultGraph and DefaultEmbedding to represent the bundle.

Field Summary

protected Map
InvariantValue>invariantValues
protected List
annotations
protected List
embeddings
protected DefaultGraph
graph
protected GraphIconFactory
graphIconFactory
protected List
listeners
protected InternationalizedProperties
properties

Constructor Summary

DefaultGraphBundle()
Default constructor.

Method Summary

void
addGraphBundleListener(GraphBundleListener listener)
void
addInvariantValue(InvariantValue value)
Add the given InvariantValue as a cached value to this bundle
int[][]
adjacencyList()
Returns a (cached) adjacency list representation for the corresponding graph.
boolean[][]
booleanAdjacencyMatrix()
Return a (cached) boolean adjacency matrix for the corresponding graph.
DefaultAnnotation
createAnnotation()
Factory method which creates a new (empty) annotation and installs it as the next annotation in this bundle, i.e., the annotation with the next available index.
DefaultEmbedding
createEmbedding()
Factory method which creates a new (empty) embedding and installs it as the next embedding in this bundle, i.e., the embedding with the next available index.
DefaultGraph
createGraph()
Factory method which creates a new (empty) graph for this bundle.
int[][]
distanceMatrix()
Returns a (cached) distance matrix for the corresponding graph.
int[]
eccentricityList()
Returns a (cached) eccentricity list for the corresponding graph.
void
fireGraphBundleChanged()
DefaultAnnotation
getAnnotation()
Return the default annotation for this graph, or null if no such annotation is stored in the bundle.
DefaultAnnotation
getAnnotation(int index)
Return the annotation with the given index.
int
getAnnotationCount()
Number of annotations stored in this bundle.
InvariantValue
getCachedInvariantValue(Invariant invariant)
Return the cached value of the graph for the given invariant, if available.
String
getDescription()
Return a textual description of this graph.
DefaultEmbedding
getEmbedding()
Return the default embedding for this graph, or null if no such embedding is stored in the bundle.
DefaultEmbedding
getEmbedding(int index)
Return the embedding with given index.
int
getEmbeddingCount()
Number of embeddings stored in this bundle.
DefaultGraph
getGraph()
Abstract graph representation for this graph bundle.
GraphIconFactory
getGraphIconFactory()
Return the preferred GraphIconFactory to be used when displaying this graph as an icon.
InvariantValue
getInvariantValue(Invariant invariant)
Return the value of the graph for the given invariant.
Collection
getInvariantValues()
Return the collection of cached values of the invariants of the graph.
Set
getInvariants()
Return the set of invariants currently registered with this bundle.
String
getName()
Return the name of this graph.
InternationalizedProperties
getProperties()
Return the internationalized properties-object for this bundle.
void
invalidate()
Clear all cached values for this bundle (i.e.
void
invalidate(InvariantValue value)
Remove the given InvariantValue from the cache of this bundle.
void
removeGraphBundleListener(GraphBundleListener listener)
void
setGraphIconFactory(GraphIconFactory graphIconFactory)
Set the graph icon factory used for displaying this graph as an icon.
void
setProperties(InternationalizedProperties properties)
Set the internationalized properties for this graph.

Field Details

InvariantValue>invariantValues

protected MapinvariantValues

annotations

protected List annotations

embeddings

protected List embeddings

graph

protected DefaultGraph graph

graphIconFactory

protected GraphIconFactory graphIconFactory

listeners

protected List listeners

properties

protected InternationalizedProperties properties

Constructor Details

DefaultGraphBundle

public DefaultGraphBundle()
Default constructor.

Method Details

addGraphBundleListener

public void addGraphBundleListener(GraphBundleListener listener)
Specified by:
addGraphBundleListener in interface GraphBundle

addInvariantValue

public void addInvariantValue(InvariantValue value)
Add the given InvariantValue as a cached value to this bundle
Specified by:
addInvariantValue in interface GraphBundle
Parameters:
value - The InvariantValue to be added to this bundle.

adjacencyList

public int[][] adjacencyList()
Returns a (cached) adjacency list representation for the corresponding graph. The resulting array contains an array of neighbour indices for every vertex. The length of each array is exactly the valency of the corresponding vertex.

Important: The return value should be considered read only and is valid only as long as the graph in the bundle is not changed.

Specified by:
adjacencyList in interface GraphBundleView

booleanAdjacencyMatrix

public boolean[][] booleanAdjacencyMatrix()
Return a (cached) boolean adjacency matrix for the corresponding graph. Row and column indices correspond to vertex indices. Entries are true when the corresponding vertices are adjacent (and different) and false otherwise.

Important: The return value should be considered read only and is valid only as long as the graph in the bundle is not changed.

Specified by:
booleanAdjacencyMatrix in interface GraphBundleView

createAnnotation

public DefaultAnnotation createAnnotation()
Factory method which creates a new (empty) annotation and installs it as the next annotation in this bundle, i.e., the annotation with the next available index.

This annotation should have the graph returned by GraphBundle.getGraph() as a peer. Subsequent calls to GraphBundle with the appropriate index, should return the annotation created by this method.

Specified by:
createAnnotation in interface GraphBundle
Returns:
the annotation created or null when the graph bundle does not support annotations.

createEmbedding

public DefaultEmbedding createEmbedding()
Factory method which creates a new (empty) embedding and installs it as the next embedding in this bundle, i.e., the embedding with the next available index.

This embedding should have the graph returned by GraphBundle.getGraph() as a peer. Subsequent calls to GraphBundle with the appropriate index, should return the embedding created by this method.

Specified by:
createEmbedding in interface GraphBundle
Returns:
the embedding created or null when the graph bundle does not support embeddings.

createGraph

public DefaultGraph createGraph()
Factory method which creates a new (empty) graph for this bundle. Subsequent calls to GraphBundle.getGraph() should return this graph.
Specified by:
createGraph in interface GraphBundle
Returns:
the graph created

distanceMatrix

public int[][] distanceMatrix()
Returns a (cached) distance matrix for the corresponding graph. Row and column indices correspond to vertex indices. Entries contains the distance between corresponding vertices or 0 when vertices are equal or belong to different components of the graph.
Specified by:
distanceMatrix in interface GraphBundleView

eccentricityList

public int[] eccentricityList()
Returns a (cached) eccentricity list for the corresponding graph. The resulting array contains the eccentricity for every vertex.

Important: The return value should be considered read only and is valid only as long as the graph in the bundle is not changed.

Specified by:
eccentricityList in interface GraphBundleView

fireGraphBundleChanged

public void fireGraphBundleChanged()

getAnnotation

public DefaultAnnotation getAnnotation()
Return the default annotation for this graph, or null if no such annotation is stored in the bundle. The peer of this annotation is the graph returned by GraphBundleView.getGraph().
Specified by:
getAnnotation in interface GraphBundleView

getAnnotation

public DefaultAnnotation getAnnotation(int index)
Return the annotation with the given index. The peer of this annotation is the graph returned by GraphBundleView.getGraph().
Specified by:
getAnnotation in interface GraphBundleView

getAnnotationCount

public int getAnnotationCount()
Number of annotations stored in this bundle.
Specified by:
getAnnotationCount in interface GraphBundleView

getCachedInvariantValue

public InvariantValue getCachedInvariantValue(Invariant invariant)
Return the cached value of the graph for the given invariant, if available.
Specified by:
getCachedInvariantValue in interface GraphBundleView
Parameters:
invariant - the URI of the invariant
Returns:
The value of the computed invariant or null if unavailable

getDescription

public String getDescription()
Return a textual description of this graph.
Specified by:
getDescription in interface GraphBundleView
Returns:
getProperties().getProperty("graph.description")

getEmbedding

public DefaultEmbedding getEmbedding()
Return the default embedding for this graph, or null if no such embedding is stored in the bundle. The peer of this embedding is the graph returned by GraphBundleView.getGraph().
Specified by:
getEmbedding in interface GraphBundleView

getEmbedding

public DefaultEmbedding getEmbedding(int index)
Return the embedding with given index. Index 0 corresponds to the default embedding. The peer of this embedding is the graph returned by GraphBundleView.getGraph().
Specified by:
getEmbedding in interface GraphBundleView

getEmbeddingCount

public int getEmbeddingCount()
Number of embeddings stored in this bundle.
Specified by:
getEmbeddingCount in interface GraphBundleView

getGraph

public DefaultGraph getGraph()
Abstract graph representation for this graph bundle.
Specified by:
getGraph in interface GraphBundle
getGraph in interface GraphBundleView

getGraphIconFactory

public GraphIconFactory getGraphIconFactory()
Return the preferred GraphIconFactory to be used when displaying this graph as an icon.
Specified by:
getGraphIconFactory in interface GraphBundleView

getInvariantValue

public InvariantValue getInvariantValue(Invariant invariant)
Return the value of the graph for the given invariant.
Specified by:
getInvariantValue in interface GraphBundleView
Parameters:
invariant - the URI of the invariant
Returns:
The value of the computed invariant or null if unavailable

getInvariantValues

public Collection getInvariantValues()
Return the collection of cached values of the invariants of the graph.
Specified by:
getInvariantValues in interface GraphBundleView
Returns:
The current collection of invariant values

getInvariants

public Set getInvariants()
Return the set of invariants currently registered with this bundle.
Specified by:
getInvariants in interface GraphBundleView

getName

public String getName()
Return the name of this graph.
Specified by:
getName in interface GraphBundleView
Returns:
getProperties().getProperty("graph.name")

getProperties

public InternationalizedProperties getProperties()
Return the internationalized properties-object for this bundle. Currently the following property keys should be supported:
  • graph.name Name of this graph.
  • graph.description Textual description of this graph.
  • embedding_i.description Textual description of the embedding with index i, with i > 0.
Specified by:
getProperties in interface GraphBundleView

invalidate

public void invalidate()
Clear all cached values for this bundle (i.e. cached InvariantValues and other cached values such as eigenvalues, adjacency lists,...).
Specified by:
invalidate in interface GraphBundle

invalidate

public void invalidate(InvariantValue value)
Remove the given InvariantValue from the cache of this bundle.
Specified by:
invalidate in interface GraphBundle
Parameters:
value - The InvariantValue to be removed from this bundle.

removeGraphBundleListener

public void removeGraphBundleListener(GraphBundleListener listener)
Specified by:
removeGraphBundleListener in interface GraphBundle

setGraphIconFactory

public void setGraphIconFactory(GraphIconFactory graphIconFactory)
Set the graph icon factory used for displaying this graph as an icon.
Specified by:
setGraphIconFactory in interface GraphBundle

setProperties

public void setProperties(InternationalizedProperties properties)
Set the internationalized properties for this graph.
Specified by:
setProperties in interface GraphBundle