de.cesr.more.rs.network
Class MRsContextJungNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>

java.lang.Object
  extended by repast.simphony.context.space.graph.ContextJungNetwork<AgentT>
      extended by de.cesr.more.rs.network.MRsContextJungNetwork<AgentT,EdgeT>
Type Parameters:
AgentT -
EdgeT -
All Implemented Interfaces:
MoreNetwork<AgentT,EdgeT>, MoreRsNetwork<AgentT,EdgeT>, repast.simphony.context.ContextListener<AgentT>, repast.simphony.space.graph.Network<AgentT>, repast.simphony.space.projection.Projection<AgentT>

public class MRsContextJungNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
extends repast.simphony.context.space.graph.ContextJungNetwork<AgentT>
implements MoreRsNetwork<AgentT,EdgeT>

MORe Network Adapter for Repast Simphony models. Extends a ContextJungNetwork (required to be used within Repast Simphony).

Date:
12.10.2010

Field Summary
protected  repast.simphony.context.Context<AgentT> context
           
protected  MoreEdgeFactory<AgentT,EdgeT> edgeFac
           
protected  repast.simphony.space.graph.JungNetwork<AgentT> network
           
protected  Class<? extends MoreNetworkBuilder<?,?>> networkBuilderClass
           
 
Constructor Summary
MRsContextJungNetwork(repast.simphony.space.graph.JungNetwork<AgentT> network, repast.simphony.context.Context<AgentT> context)
           
MRsContextJungNetwork(repast.simphony.space.graph.JungNetwork<AgentT> network, repast.simphony.context.Context<AgentT> context, MoreEdgeFactory<AgentT,EdgeT> edgeFac)
           
 
Method Summary
 EdgeT addEdge(AgentT source, AgentT target)
           
 void addNode(AgentT node)
          Add a node to the network.
 EdgeT connect(AgentT source, AgentT target)
          If there is already a connection object between these nodes it is removed and the given one added.
 void connect(EdgeT edge)
          Adds an edge to this network.
 boolean containsNode(AgentT node)
          Return true if the given node is contained within this network
 EdgeT disconnect(AgentT source, AgentT target)
           
 EdgeT getEdge(AgentT source, AgentT target)
           
 Collection<EdgeT> getEdgesCollection()
           
 MoreNetwork<AgentT,EdgeT> getGraphFilteredInstance(Graph<AgentT,EdgeT> graph, String newName)
          The method is used to obtain a new Sub-MoreNetwork.
 Graph<AgentT,EdgeT> getJungGraph()
          Return a JUNG Graph object of this network.
 double getMeasureA()
          Accessing network measures by Repast Simphony
 double getMeasureB()
           
 Class<? extends MoreNetworkBuilder<?,?>> getNetworkBuilderClass()
           
 String getNetworkInfo()
          Provides some basic oinformation on the network: - number of links - number of edges - directedness
 double getWeight(AgentT source, AgentT target)
           
 void normalizeWeights()
          Normalises the edges' weights by dividing by the largest weight.
 int numNodes()
           
 void removeNode(AgentT node)
          Removes a node and all its edges from the network.
 void reverseNetwork()
          Returns a reversed network, i.e. for all edges source and target vertices are exchanged.
 void setEdgeFactory(MoreEdgeFactory<AgentT,EdgeT> edgeFac)
          Sets the MoreEdgeFactory that is used to connect agents.
 void setMeasureA(MMeasureDescription desc)
           
 void setMeasureB(MMeasureDescription desc)
           
 void setNetworkBuilderClass(Class<? extends MoreNetworkBuilder<?,?>> builderClass)
           
 void setWeight(AgentT source, AgentT target, double weight)
           
 String toString()
           
 
Methods inherited from class repast.simphony.context.space.graph.ContextJungNetwork
addAll, addEdge, addEdge, addProjectionListener, addVertex, containsEdge, equals, evaluate, eventOccured, getAdjacent, getDegree, getDegree, getEdgeCreator, getEdges, getEdges, getGraph, getInDegree, getInEdges, getName, getNodes, getOutDegree, getOutEdges, getPredecessors, getProjectionListeners, getRandomAdjacent, getRandomPredecessor, getRandomSuccessor, getSuccessors, hashCode, isAdjacent, isDirected, isPredecessor, isSuccessor, numEdges, removeAll, removeEdge, removeEdges, removeProjectionListener, removeVertex, setGraph, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface repast.simphony.context.ContextListener
eventOccured
 
Methods inherited from interface de.cesr.more.basic.network.MoreNetwork
getAdjacent, getDegree, getInDegree, getName, getNodes, getOutDegree, getPredecessors, getRandomPredecessor, getRandomSuccessor, getSuccessors, isAdjacent, isDirected, isSuccessor, numEdges
 
Methods inherited from interface repast.simphony.space.graph.Network
addEdge, addEdge, containsEdge, getAdjacent, getDegree, getDegree, getEdgeCreator, getEdges, getEdges, getInDegree, getInEdges, getNodes, getOutDegree, getOutEdges, getPredecessors, getRandomAdjacent, getRandomPredecessor, getRandomSuccessor, getSuccessors, isAdjacent, isDirected, isPredecessor, isSuccessor, numEdges, removeEdge, removeEdges, size
 
Methods inherited from interface repast.simphony.space.projection.Projection
addProjectionListener, evaluate, getName, getProjectionListeners, removeProjectionListener
 

Field Detail

context

protected repast.simphony.context.Context<AgentT> context

network

protected repast.simphony.space.graph.JungNetwork<AgentT> network

edgeFac

protected MoreEdgeFactory<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>> edgeFac

networkBuilderClass

protected Class<? extends MoreNetworkBuilder<?,?>> networkBuilderClass
Constructor Detail

MRsContextJungNetwork

public MRsContextJungNetwork(repast.simphony.space.graph.JungNetwork<AgentT> network,
                             repast.simphony.context.Context<AgentT> context)
Parameters:
net -
context -

MRsContextJungNetwork

public MRsContextJungNetwork(repast.simphony.space.graph.JungNetwork<AgentT> network,
                             repast.simphony.context.Context<AgentT> context,
                             MoreEdgeFactory<AgentT,EdgeT> edgeFac)
Parameters:
net -
context -
Method Detail

addNode

public void addNode(AgentT node)
Description copied from interface: MoreNetwork
Add a node to the network.

Specified by:
addNode in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.addNode(java.lang.Object)

connect

public EdgeT connect(AgentT source,
                     AgentT target)
Description copied from interface: MoreNetwork
If there is already a connection object between these nodes it is removed and the given one added.

Specified by:
connect in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
the new edge
See Also:
Tries to use the {@link MDefaultEdgeFactory} in case no {@link MoreEdgeFactory} has been set before. This fails if EdgeT is not {@link MoreEdge

disconnect

public EdgeT disconnect(AgentT source,
                        AgentT target)
Specified by:
disconnect in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.disconnect(java.lang.Object, java.lang.Object)

getWeight

public double getWeight(AgentT source,
                        AgentT target)
Specified by:
getWeight in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
the weight of the edge between source and target node
See Also:
MoreNetwork.getWeight(java.lang.Object, java.lang.Object)

normalizeWeights

public void normalizeWeights()
Description copied from interface: MoreNetwork
Normalises the edges' weights by dividing by the largest weight.

Specified by:
normalizeWeights in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.normalizeWeights()

numNodes

public int numNodes()
Specified by:
numNodes in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
the number of nodes in this network
See Also:
MoreNetwork.numNodes()

setWeight

public void setWeight(AgentT source,
                      AgentT target,
                      double weight)
Specified by:
setWeight in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.setWeight(java.lang.Object, java.lang.Object, double)

getEdge

public EdgeT getEdge(AgentT source,
                     AgentT target)
Specified by:
getEdge in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Specified by:
getEdge in interface repast.simphony.space.graph.Network<AgentT>
Overrides:
getEdge in class repast.simphony.context.space.graph.ContextJungNetwork<AgentT>
See Also:
ContextJungNetwork.getEdge(java.lang.Object, java.lang.Object)

getMeasureA

public double getMeasureA()
Description copied from interface: MoreRsNetwork
Accessing network measures by Repast Simphony

Specified by:
getMeasureA in interface MoreRsNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreRsNetwork.getMeasureA()

getMeasureB

public double getMeasureB()
Specified by:
getMeasureB in interface MoreRsNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreRsNetwork.getMeasureB()

setMeasureA

public void setMeasureA(MMeasureDescription desc)
                 throws MIllegalValueTypeException
Specified by:
setMeasureA in interface MoreRsNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Throws:
MIllegalValueTypeException
See Also:
MoreRsNetwork.setMeasureA(de.cesr.more.measures.MMeasureDescription)

setMeasureB

public void setMeasureB(MMeasureDescription desc)
                 throws MIllegalValueTypeException
Specified by:
setMeasureB in interface MoreRsNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Throws:
MIllegalValueTypeException
See Also:
MoreRsNetwork.setMeasureB(de.cesr.more.measures.MMeasureDescription)

getGraphFilteredInstance

public MoreNetwork<AgentT,EdgeT> getGraphFilteredInstance(Graph<AgentT,EdgeT> graph,
                                                          String newName)
Description copied from interface: MoreNetwork
The method is used to obtain a new Sub-MoreNetwork. The parameter is a Graph instance that contains subsets of vertices and edges in the original MoreNetwork this method is applied to. For instance, such graphs may be a result of a VertexPredicateFilter. The given graph needs to be of corresponding directedness! This (the original) instance of MoreNetwork is not altered!

Specified by:
getGraphFilteredInstance in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
A new MoreNetwork containing only vertices and edges contained in given graph object
See Also:
de.cesr.more.basic.network.MoreNetwork#getGraphFilteredInstance(edu.uci.ics.jung.graph.Graph)

getJungGraph

public Graph<AgentT,EdgeT> getJungGraph()
Description copied from interface: MoreNetwork
Return a JUNG Graph object of this network.

Specified by:
getJungGraph in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
a JUNG Graph object of this network
See Also:
MoreNetwork.getJungGraph()

toString

public String toString()
Overrides:
toString in class repast.simphony.context.space.graph.ContextJungNetwork<AgentT>
See Also:
ContextJungNetwork.toString()

reverseNetwork

public void reverseNetwork()
Description copied from interface: MoreNetwork
Returns a reversed network, i.e. for all edges source and target vertices are exchanged.

Specified by:
reverseNetwork in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
Tries to use the {@link MDefaultEdgeFactory} in case no {@link MoreEdgeFactory} has been set before. This fails if EdgeT is not {@link MoreEdge

getEdgesCollection

public Collection<EdgeT> getEdgesCollection()
Specified by:
getEdgesCollection in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
collection of all edges
See Also:
MoreNetwork.getEdgesCollection()

addEdge

public EdgeT addEdge(AgentT source,
                     AgentT target)
Specified by:
addEdge in interface repast.simphony.space.graph.Network<AgentT>
Overrides:
addEdge in class repast.simphony.context.space.graph.ContextJungNetwork<AgentT>
See Also:
de.cesr.more.basic.network.MoreNetwork#connect(java.lang.Object)

connect

public void connect(EdgeT edge)
Description copied from interface: MoreNetwork
Adds an edge to this network. Implementing classes are required to use the edge factory.

Specified by:
connect in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Parameters:
edge - to add to the network
See Also:
de.cesr.more.basic.network.MoreNetwork#connect(java.lang.Object)

removeNode

public void removeNode(AgentT node)
Description copied from interface: MoreNetwork
Removes a node and all its edges from the network.

Specified by:
removeNode in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.removeNode(java.lang.Object)

setEdgeFactory

public void setEdgeFactory(MoreEdgeFactory<AgentT,EdgeT> edgeFac)
Description copied from interface: MoreNetwork
Sets the MoreEdgeFactory that is used to connect agents.

Specified by:
setEdgeFactory in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.setEdgeFactory(de.cesr.more.building.edge.MoreEdgeFactory)

containsNode

public boolean containsNode(AgentT node)
Description copied from interface: MoreNetwork
Return true if the given node is contained within this network

Specified by:
containsNode in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
Returns:
true if the network contains the given node
See Also:
MoreNetwork.containsNode(java.lang.Object)

getNetworkBuilderClass

public Class<? extends MoreNetworkBuilder<?,?>> getNetworkBuilderClass()
Specified by:
getNetworkBuilderClass in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.getNetworkBuilderClass()

setNetworkBuilderClass

public void setNetworkBuilderClass(Class<? extends MoreNetworkBuilder<?,?>> builderClass)
Specified by:
setNetworkBuilderClass in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.setNetworkBuilderClass(java.lang.Class)

getNetworkInfo

public String getNetworkInfo()
Description copied from interface: MoreNetwork
Provides some basic oinformation on the network: - number of links - number of edges - directedness

Specified by:
getNetworkInfo in interface MoreNetwork<AgentT,EdgeT extends repast.simphony.space.graph.RepastEdge<AgentT> & MoreEdge<AgentT>>
See Also:
MoreNetwork.getNetworkInfo()