peersim.graph
Class FastUndirGraph

java.lang.Object
  extended by peersim.graph.ConstUndirGraph
      extended by peersim.graph.FastUndirGraph
All Implemented Interfaces:
Graph

public class FastUndirGraph
extends ConstUndirGraph

Speeds up ConstUndirGraph.isEdge(int, int) by storing the links in an adjacency matrix (in fact in a triangle). Its memory consumption is huge but it's much faster if the isEdge method of the original underlying graph is slow.


Field Summary
 
Fields inherited from class peersim.graph.ConstUndirGraph
g, in
 
Constructor Summary
FastUndirGraph(Graph graph)
          Calls super constructor
 
Method Summary
protected  void initGraph()
          Finds and stores incoming edges
 boolean isEdge(int i, int j)
          Returns true if there is a directed edge between node i and node j.
 
Methods inherited from class peersim.graph.ConstUndirGraph
clearEdge, degree, directed, getEdge, getNeighbours, getNode, setEdge, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastUndirGraph

public FastUndirGraph(Graph graph)
Calls super constructor

Method Detail

initGraph

protected void initGraph()
Description copied from class: ConstUndirGraph
Finds and stores incoming edges

Overrides:
initGraph in class ConstUndirGraph

isEdge

public boolean isEdge(int i,
                      int j)
Description copied from interface: Graph
Returns true if there is a directed edge between node i and node j.

Specified by:
isEdge in interface Graph
Overrides:
isEdge in class ConstUndirGraph