es.yrbcn.graph.triangles
Class TrianglesAlgorithm

java.lang.Object
  extended by es.yrbcn.graph.triangles.TrianglesAlgorithm
Direct Known Subclasses:
BitbasedTrianglesAlgorithm, SamplingTrianglesAlgorithm

public abstract class TrianglesAlgorithm
extends Object

This is an abstract algorithm for counting the number of triangles for the nodes in a graph.


Field Summary
 short DEFAULT_WIDTH
          Default width
 boolean done
          done or not
 ImmutableGraph graph
          The graph.
 short maxDistance
          The maximum distance for the iterations
 int numNodes
          The number of nodes.
 MersenneTwister random
          Random number generator; all random numbers should be created using this generator
 double[] triangles
          Estimation
 
Constructor Summary
TrianglesAlgorithm()
           
TrianglesAlgorithm(ImmutableGraph graph, int seed, short maxDistance)
          Creates a new TrianglesAlgorithm run; the algorithm will count how many triangles each element has
 
Method Summary
abstract  void countTriangles()
           
 boolean done()
           
protected abstract  void init()
          Initializes one run of the algorithm
abstract  void step()
          Does one step of the algorithm; this is called until done()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

public final short DEFAULT_WIDTH
Default width

See Also:
Constant Field Values

maxDistance

public short maxDistance
The maximum distance for the iterations


graph

public ImmutableGraph graph
The graph.


numNodes

public int numNodes
The number of nodes.


done

public boolean done
done or not


triangles

public double[] triangles
Estimation


random

public MersenneTwister random
Random number generator; all random numbers should be created using this generator

Constructor Detail

TrianglesAlgorithm

public TrianglesAlgorithm()

TrianglesAlgorithm

public TrianglesAlgorithm(ImmutableGraph graph,
                          int seed,
                          short maxDistance)
Creates a new TrianglesAlgorithm run; the algorithm will count how many triangles each element has

Parameters:
g - the graph.
width - the number of bits to use (32)
seed - the random seed for the random number generator
maxDistance - the distance to explore
Method Detail

done

public boolean done()

init

protected abstract void init()
Initializes one run of the algorithm


step

public abstract void step()
                   throws FileNotFoundException,
                          IOException
Does one step of the algorithm; this is called until done()

Throws:
FileNotFoundException
IOException

countTriangles

public abstract void countTriangles()
                             throws IOException
Throws:
IOException