peersim.reports
Class GraphObserver

java.lang.Object
  extended by peersim.reports.GraphObserver
All Implemented Interfaces:
Control
Direct Known Subclasses:
BallExpansion, Clustering, ConnectivityObserver, DegreeStats, GraphPrinter, GraphStats, InetObserver, RandRemoval

public abstract class GraphObserver
extends java.lang.Object
implements Control

Class that provides functionality for observing graphs. It can efficiently create an undirected version of the graph, making sure it is updated only when the simulation has advanced already, and provides some common parameters.


Parameter Summary
protocol
          The protocol to operate on.
undir
          If defined, the undirected version of the graph will be analyzed.
undirected
          Alias for "undir".
graphobserver.fast
          If defined, the undirected version of the graph will be stored using much more memory but observers will be in general a few times faster.
 
Field Summary
protected  Graph g
           
protected  GraphAlgorithms ga
           
protected  java.lang.String name
          The name of this observer in the configuration
protected  int pid
           
protected  boolean undir
           
 
Constructor Summary
protected GraphObserver(java.lang.String name)
          Standard constructor that reads the configuration parameters.
 
Method Summary
protected  void updateGraph()
          Sets g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface peersim.core.Control
execute
 

Parameter Detail

protocol

The protocol to operate on.


undir

If defined, the undirected version of the graph will be analyzed. Not defined by default.


undirected

Alias for "undir".


graphobserver.fast

If defined, the undirected version of the graph will be stored using much more memory but observers will be in general a few times faster. As a consequence, it will not work with large graphs. Not defined by default. It is a static property, that is, it affects all graph observers that are used in a simulation. That is, it is not a parameter of any observer, the name should be specified as a standalone property.

Field Detail

name

protected final java.lang.String name
The name of this observer in the configuration


pid

protected final int pid

undir

protected final boolean undir

ga

protected final GraphAlgorithms ga

g

protected Graph g
Constructor Detail

GraphObserver

protected GraphObserver(java.lang.String name)
Standard constructor that reads the configuration parameters. Invoked by the simulation engine.

Parameters:
name - the configuration prefix for this class
Method Detail

updateGraph

protected void updateGraph()
Sets g. It MUST be called by any implementation of Control.execute() before doing anything else. Attempts to initialize g from a pre-calculated graph stored in a static field, but first it checks whether it needs to be updated. If the simulation time has progressed or it was calculated for a different protocol, then updates this static graph as well. The purpose of this mechanism is to save the time of constructing the graph if many observers are run on the same graph. Time savings can be very significant if the undirected version of the same graph is observed by many observers.