|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.ipk_gatersleben.ag_nw.centilib.utils.GraphCachingUtils<V,E>
public class GraphCachingUtils<V,E>
All values like centrality values, graph properties, edge weights or connected components can be stored and accessed via this class.
As default, the cache is not activated to avoid unreliable values when a graph changes. If you want to store values activate
the cache via setUseCache(true) and make sure to remove a graph and its values if a node or an edge was added or removed because already
computed values get unreliable.
If the cache is activated, every time a method is called for an unknown graph an instance of Distance
is created. It computes
and stores the distances between the nodes of a graph. If edge weights are set, weighted shortest paths will be computed. Make use
of this instance via getDistance(graph), to compute a shortest path only if needed and only once.
If a value is not available yet, it will
be computed (and stored if the chache is activated) automatically. This is not true for centralities. Use CentralityHandler
to compute centralities.
Constructor Summary | |
---|---|
GraphCachingUtils()
|
Method Summary | ||
---|---|---|
static
|
addGraphCentrality(Graph<V,E> graph,
String centName,
Double value)
Adds the given graph centrality value for graph to the cache. |
|
static
|
addScorer(Graph<V,E> graph,
VertexCentrality<V,E> scorer,
String name)
Adds the given node centrality for graph to the cache. |
|
static
|
containsParallelEdges(Graph<V,E> graph)
Determines whether graph contains parallel edges or not. |
|
static
|
containsSelfLoops(Graph<V,E> graph)
Determines whether graph contains self loops or not. |
|
static
|
getAvailableScorerNames(Graph<V,E> graph)
Returns the list of names of already computed centralities for the given graph. |
|
static
|
getConnectedComponents(Graph<V,E> graph)
Returns a set of connected components for the given graph. |
|
static
|
getDistance(Graph<V,E> graph)
Returns an instance of the interface Distance for the given graph. |
|
static
|
getEdgesOfComponent(Graph<V,E> graph,
Set<V> vertices)
Returns the edges between the given vertices. |
|
static
|
getEdgeWeights(Graph<V,E> graph)
Returns the edge weights for the given graph, if they exist. |
|
static
|
getEdgeWeightTransformer(Graph<V,E> graph)
Returns a transformer for edge weights if they were set. |
|
static
|
getGraphCentrality(Graph<V,E> graph,
String centName)
Returns the requested centrality value for the given graph if it exists. |
|
static
|
getGraphName(Graph<V,E> graph)
Returns the name of the given graph, if it exists. |
|
static
|
getGraphs()
Returns the list of known graphs. |
|
static
|
getLastEdgeAttribute(Graph<V,E> graph)
Returns the last edge attribute for the given graph if it exists. |
|
static
|
getLastScorer(Graph<V,E> graph)
Returns the currently selected centrality instance for graph. |
|
static
|
getLastScorerName(Graph<V,E> graph)
Returns the name of the last scorer that was added to the cache. |
|
static
|
getResultList(Graph<V,E> graph,
VertexCentrality<V,E> ranker)
This method is for CentiLib internal use only (result panel). |
|
static
|
getScorer(Graph<V,E> graph,
String scorerName)
Returns the centrality with name scorerName for the given graph. |
|
static
|
getShortestPath(Graph<V,E> graph)
Returns an instance of the interface ShortestPath for the given graph. |
|
static
|
getStrongConnectedComponents(Graph<V,E> graph)
Returns a set of strongly connected components for the given graph. |
|
static
|
isConnected(Graph<V,E> graph)
Determines whether the given graph is connected or not. |
|
static
|
isDirected(Graph<V,E> graph)
Determines whether graph is directed or not. |
|
static
|
isStrongConnected(Graph<V,E> graph)
Determines whether graph is strongly connected or not. |
|
static
|
isUndirected(Graph<V,E> graph)
Determines whether graph is undirected or not. |
|
static
|
remove(Graph<V,E> graph)
Removes the given graph and all it's values from the cache. |
|
static void |
removeAllGraphsFromCache()
Removes all graphs from the cache. |
|
static
|
removeEdgeWeights(Graph<V,E> graph)
Removes existing edge weights for the given graph. |
|
static
|
setEdgeWeights(Graph<V,E> graph,
Map<E,Number> weights)
Stores the given weights for the graph 'graph'. |
|
static
|
setGraphName(Graph<V,E> graph,
String name)
Stores the name of a graph. |
|
static
|
setLastEdgeAttribute(Graph<V,E> graph,
DoubleAttribute<E> attribute)
Sets the current edge attribute for the given graph. |
|
static
|
setResultList(Graph<V,E> graph,
VertexCentrality<V,E> ranker,
org.apache.commons.collections15.BidiMap<V,Integer> list)
This method is for CentiLib internal use only (result panel). |
|
static void |
setUseCache(boolean useCache)
Sets whether to store computed values or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphCachingUtils()
Method Detail |
---|
public static void setUseCache(boolean useCache)
useCache
- True if values should be stored.public static <V,E> void setGraphName(Graph<V,E> graph, String name)
V
- Type of nodes.E
- Type of edges.graph
- The graph to store the name for.name
- The name of the given graph.public static <V,E> String getGraphName(Graph<V,E> graph)
V
- Type of nodes.E
- Type of edges.graph
- The graph to return the name for.
public static <V,E> boolean setEdgeWeights(Graph<V,E> graph, Map<E,Number> weights)
V
- Type of the verticesE
- Type of the edgesgraph
- The graph for which the edge weights will be storedweights
- A Map to resolve the weights for all edges
public static <V,E> void setLastEdgeAttribute(Graph<V,E> graph, DoubleAttribute<E> attribute)
V
- Type of nodesE
- Type of edgesgraph
- The graph to store the attribute for.attribute
- The attribute to store.public static <V,E> void removeEdgeWeights(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to remove the edge weights for.public static <V,E> Map<E,Number> getEdgeWeights(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to get edge weights for.
public static <V,E> org.apache.commons.collections15.Transformer<E,Double> getEdgeWeightTransformer(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to get the transformer for.
public static <V,E> DoubleAttribute<E> getLastEdgeAttribute(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to get the attribute for.
public static <V,E> Collection<Graph<V,E>> getGraphs()
V
- Type of nodesE
- Type of edges
public static <V,E> Double getGraphCentrality(Graph<V,E> graph, String centName)
V
- Type of nodesE
- Type of edgesgraph
- The graph a centrality should be returned forcentName
- The name of the centrality to get for the given graph
public static <V,E> Distance<V> getDistance(Graph<V,E> graph)
Distance
for the given graph. It computes and stores the
lengths of shortest paths for a single graph. If edge weights were set, they will be taken into account.
V
- Type of nodesE
- Type of edgesgraph
- The graph to get the distances for.
public static <V,E> ShortestPath<V,E> getShortestPath(Graph<V,E> graph)
ShortestPath
for the given graph. In contrast to
the interface Distance
V
- Type of nodesE
- Type of edgesgraph
- The graph to shortest paths for.
public static <V,E> boolean isConnected(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
-
public static <V,E> boolean isStrongConnected(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to check.
public static <V,E> boolean isDirected(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to check.
public static <V,E> boolean isUndirected(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to check.
public static <V,E> boolean containsSelfLoops(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to find self loops in.
public static <V,E> boolean containsParallelEdges(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to find parallel edeges in.
public static <V,E> void addGraphCentrality(Graph<V,E> graph, String centName, Double value)
V
- Type of nodesE
- Type of edgesgraph
- The graph to store the centrality value forcentName
- The name of the graph centralityvalue
- The value of the graph centralitypublic static <V,E> void addScorer(Graph<V,E> graph, VertexCentrality<V,E> scorer, String name)
V
- Type of nodesE
- Type of edgesgraph
- The graph to store the centrality for.scorer
- The instance that contains the centrality values.name
- The name of the centralitypublic static <V,E> VertexCentrality<V,E> getLastScorer(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to return the lastly added centrality for.
public static <V,E> String getLastScorerName(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to get the name of the lastly added centrality for.
public static <V,E> VertexCentrality<V,E> getScorer(Graph<V,E> graph, String scorerName)
V
- Type of nodesE
- Type of edgesgraph
- The graph to return the centrality for.scorerName
- The name of the centrality
public static <V,E> Collection<String> getAvailableScorerNames(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
-
public static <V,E> org.apache.commons.collections15.BidiMap<V,Integer> getResultList(Graph<V,E> graph, VertexCentrality<V,E> ranker)
V
- Type of nodesE
- Type of edgesgraph
- !document me!ranker
- !document me!
public static <V,E> void setResultList(Graph<V,E> graph, VertexCentrality<V,E> ranker, org.apache.commons.collections15.BidiMap<V,Integer> list)
V
- Type of nodesE
- Type of edgesgraph
- !document me!ranker
- !document me!list
- !document me!public static <V,E> Set<Set<V>> getConnectedComponents(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to return the connected components for.
public static <V,E> Set<Set<V>> getStrongConnectedComponents(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to return the strongly connected components for.
public static <V,E> Set<E> getEdgesOfComponent(Graph<V,E> graph, Set<V> vertices)
V
- Type of nodesE
- Type of edgesgraph
- The graph the vertices and edges belong to.vertices
- The nodes to get the edges for.
public static <V,E> void remove(Graph<V,E> graph)
V
- Type of nodesE
- Type of edgesgraph
- The graph to remove from the cache.public static void removeAllGraphsFromCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |