My Project
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
ClusterAlg< R > Class Template Reference

Base class for all community detection algorithms. More...

#include <cluster.h>

Inheritance diagram for ClusterAlg< R >:
CliqueCluster< R > CONGA< R > COPRA< R > IterativeDensity< R > LCOMM< R > OSLOM< R > RRW< R > SLPA< R > SSDE< R >

List of all members.

Public Member Functions

virtual void calculate ()=0
float get_Density (bidirected_t::graph *graph, const set< bidirected_t::vertex > *cluster)
float get_Density (set< lui > *cluster)
bool ReadGraph (ifstream *fin, string delimiters=" ,\t", double alpha=1, double beta=1)
bool PrintGraph (ofstream *fout)
bool PrintCommunities (string filename)
void PrintCommunity (set< lui > *comm)
bool PrintTranslatedCommunities (string filename)
void PrintTranslatedCommunity (set< lui > *comm)
void TranslateCommunities ()
void setOutput (string filename)

Static Public Member Functions

static ClusterAlgCreate (string type, string args, double alpha, double beta, double weightThresh, bool translate)

Public Attributes

map< lui, map< lui, R > > network
vector< set< lui > > communities
map< string, luiidmap
map< lui, string > idLookup
string args
bool translate
ostream * fileout

Static Public Attributes

static density< bidirected_t > * dens

Detailed Description

template<typename R>
class ClusterAlg< R >

Base class for all community detection algorithms.

Holds general purpose functions for all algorithms, but main purpose is as a factory, to create the correct class at runtime.


Member Function Documentation

template<typename R >
virtual void ClusterAlg< R >::calculate ( ) [pure virtual]

Will be the actual algorithm implementation.

Implemented in IterativeDensity< R >, CliqueCluster< R >, SLPA< R >, CONGA< R >, RRW< R >, OSLOM< R >, COPRA< R >, SSDE< R >, and LCOMM< R >.

template<typename R >
template ClusterAlg< double > * ClusterAlg< R >::Create ( string  type,
string  args,
double  alpha,
double  beta,
double  weightThresh,
bool  translate 
) [static]

Factory function

Parameters:
typeAlgorithm to create class for
argListArguments to use for algorithm
alphaFactor for positive weights
betaFactor for negative weights
weightThreshMinimum edge weight
Returns:
Cluster algorithm set up to implement 'type' algorithm

Factory function

Parameters:
typeAlgorithm to create class for
argListArguments to use for algorithm
alphaFactor for positive weights
betaFactor for negative weights
weightThreshMinimum edge weight
translateFlag indicating whether or not to use original vertex names (from file)
Returns:
Class set up to implement 'type' detection algorithm
template<typename R >
float ClusterAlg< R >::get_Density ( bidirected_t::graph graph,
const set< bidirected_t::vertex > *  cluster 
) [inline]

Retrieve the density of a set of vertices in a graph using boost structures.

Parameters:
graphThe network the cluster is from
clusterSet of vertices in the cluster
Returns:
Cluster density value
template<typename R >
float ClusterAlg< R >::get_Density ( set< lui > *  cluster) [inline]

Retrieve density of a set of vertices

Parameters:
clusterIDs of vertices in the community
Returns:
Cluster density value
template<typename R >
bool ClusterAlg< R >::PrintCommunities ( string  filename) [inline]

Print detected communities to file. Each line in the output file is as follows:

CommunityDensity CommunitySize Vertex1ID Vertex2ID Vertex3ID ...

Parameters:
filenameString representing filename to print communities to
Returns:
true

Reimplemented in IterativeDensity< R >.

template<typename R >
void ClusterAlg< R >::PrintCommunity ( set< lui > *  comm) [inline]

Print a single community to the out file

CommunityDensity CommunitySize Vertex1ID Vertex2ID Vertex3ID ...

Parameters:
commSet of vertices to print out
template<typename R >
bool ClusterAlg< R >::PrintGraph ( ofstream *  fout) [inline]

Print the network to a file

Parameters:
foutStream to print file to
Returns:
true
template<typename R >
bool ClusterAlg< R >::PrintTranslatedCommunities ( string  filename) [inline]

Print detected communities to file. Each line in the output file is as follows:

CommunityDensity CommunitySize Vertex1 Vertex2 Vertex3 ...

Parameters:
filenameString representing filename to print communities to
Returns:
true

Reimplemented in IterativeDensity< R >.

template<typename R >
void ClusterAlg< R >::PrintTranslatedCommunity ( set< lui > *  comm) [inline]

Print a single community to the out file (with translated names)

CommunityDensity CommunitySize Vertex1_OriginalID Vertex2_OriginalID Vertex3_OriginalID ...

Parameters:
commSet of vertices to print out
template<typename R >
bool ClusterAlg< R >::ReadGraph ( ifstream *  fin,
string  delimiters = " ,\t",
double  alpha = 1,
double  beta = 1 
) [inline]

Read network from a file and save. Each vertex read in is given a numerical ID that it used throughout the detection process. (Easier comparison between numbers than strings). This can be translated back later.

Parameters:
finStream to read network from
delimitersDelimiters between the vertex IDs and edge weights in the network file.
Returns:
true
template<typename R >
void ClusterAlg< R >::TranslateCommunities ( ) [inline]

As long as the original vertex IDs were also numerical (integers), this function will retrieve the original vertex IDs without printing out the communities. Useful for comparing results to benchmark 'ground truth's.

Reimplemented in IterativeDensity< R >.


Member Data Documentation

template<typename R >
string ClusterAlg< R >::args

Clustering Algorithm Arguments

template<typename R >
vector< set < lui > > ClusterAlg< R >::communities

Structure to hold resulting communities

template<typename R >
density< bidirected_t > * ClusterAlg< R >::dens [static]

Community density calculation method to use

template<typename R >
ostream* ClusterAlg< R >::fileout

Place to print output

template<typename R >
map<lui, string> ClusterAlg< R >::idLookup

For faster translating

template<typename R >
map<string, lui> ClusterAlg< R >::idmap

Holds map to original vertex names

template<typename R >
map<lui, map <lui, R> > ClusterAlg< R >::network

Structure to hold network

template<typename R >
bool ClusterAlg< R >::translate

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs