edu.upc.dama.dex.algorithms
Class Connectivity

java.lang.Object
  extended by edu.upc.dama.dex.tasks.Task
      extended by edu.upc.dama.dex.tasks.CompositeTask
          extended by edu.upc.dama.dex.algorithms.Connectivity
All Implemented Interfaces:
Algorithm
Direct Known Subclasses:
StrongConnectivity, WeakConnectivity

public abstract class Connectivity
extends edu.upc.dama.dex.tasks.CompositeTask
implements Algorithm

Any class implementing this abstract class can be used to solve a problem related to graph connectivity as finding the strongly connected components or finding the weakly connected components. Any component of a graph is called connected if there is a path between every pair of nodes contained in this component.

Author:
Sparsity Technologies

Field Summary
 
Fields inherited from interface edu.upc.dama.dex.algorithms.Algorithm
NAVIGATION_BACKWARD, NAVIGATION_FORWARD, NAVIGATION_UNDIRECTED
 
Constructor Summary
Connectivity(Graph graph)
          Creates a new instance of Connectivity.
 
Method Summary
 void addAllEdges()
          Adds all the edge types contained in the graph in order to restrict the set of edge types allowed while traversing the graph.
 void addAllNodes()
          Adds all the node types contained in the graph to restrict the set of allowed node types.
 void addEdge(int edgetype)
          Adds an edge type in order to restrict the set of edge types allowed while traversing the graph.
 void addNode(int nodetype)
          Adds a node type in order to restrict the set of allowed node types while traversing the graph.
abstract  void close()
          Closes the instance.
 ConnectedComponents getConnectedComponents()
          Returns the results generated by the execution of the algorithm.
abstract  void run()
          Runs the algorithm in order to find the connected components.
 void setMaterializedAttribute(java.lang.String nameattribute)
          Creates a new common attribute type for all node types in the graph in order to store, persistently, the results related to the connected components found while executing this algorithm.
 
Methods inherited from class edu.upc.dama.dex.tasks.CompositeTask
cancel, execute, init
 
Methods inherited from class edu.upc.dama.dex.tasks.Task
main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connectivity

public Connectivity(Graph graph)
Creates a new instance of Connectivity.

Parameters:
graph - Graph on which the algorithm will be run.
Method Detail

addAllEdges

public void addAllEdges()
Adds all the edge types contained in the graph in order to restrict the set of edge types allowed while traversing the graph.


addEdge

public void addEdge(int edgetype)
Adds an edge type in order to restrict the set of edge types allowed while traversing the graph. It is possible to add as many edge types as all the different edge types contained in the graph.

Parameters:
edgetype - The edge type to restrict the set of edges allowed while traversing the graph during the execution of the algorithm.

addAllNodes

public void addAllNodes()
Adds all the node types contained in the graph to restrict the set of allowed node types.


addNode

public void addNode(int nodetype)
Adds a node type in order to restrict the set of allowed node types while traversing the graph. It is possible to add as many node types as all the different node types contained in the graph.

Parameters:
nodetype - The node type to restrict the set of nodes allowed while traversing the graph during the execution of the algorithm.

close

public abstract void close()
Closes the instance.

Once executed, the instance becomes invalid.


getConnectedComponents

public ConnectedComponents getConnectedComponents()
Returns the results generated by the execution of the algorithm. These results contain information related to the connected components found as the number of different components, the set of nodes contained in each component or many other data.

Returns:
Returns an instance of the class ConnectedComponents which contain information related to the connected components found.

run

public abstract void run()
                  throws java.lang.Throwable
Runs the algorithm in order to find the connected components.

This method can be called only once.

Throws:
java.lang.Throwable

setMaterializedAttribute

public void setMaterializedAttribute(java.lang.String nameattribute)
Creates a new common attribute type for all node types in the graph in order to store, persistently, the results related to the connected components found while executing this algorithm.

Whenever the user wants to retrieve the results, even when the graph has been closed and opened again, it is only necessary to create a new isntance of the class ConnectedComponents indicating the graph and the name of the common attribute type which stores the results. This instance will have all the information related to the connected components found in the moment of the execution of the algorithm that stored this data.

It is possible to run the algorithm without specifying this parameter in order to avoid materializing the results of the execution.

Parameters:
nameattribute - The name of the common attribute type for all node types in the graph which will store persistently the results generated by the execution of the algorithm.