Class ContextJungNetwork<T>
java.lang.Object
repast.simphony.context.space.graph.ContextJungNetwork<T>
- All Implemented Interfaces:
ContextListener<T>
,Network<T>
,Projection<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAll()
addEdge
(RepastEdge<T> edge) Adds the specified edge to this Network.Adds an edge between the specified objects.Adds an edge between the specified objects.void
addProjectionListener
(ProjectionListener listener) Adds listener for this projection.void
boolean
containsEdge
(RepastEdge<T> edge) Returns whether or not this network contains the specified edge.boolean
boolean
evaluate
(ProjectionPredicate predicate) Evaluate this Projection against the specified Predicate.void
eventOccured
(ContextEvent<T> ev) Called to nofify the listener of a change to a context.getAdjacent
(T agent) Gets any objects that are adjacent to this object.int
Get the total degree (number of edges) for the graph.int
Gets the degree of the node associated with the specified object.Retrieves the edge between the specified source and target.EdgeCreator<? extends RepastEdge<T>,
T> Gets the EdgeCreator used to create edges for this Network.getEdges()
Gets all the edges in this Network.Gets all the edges where the specified object is a source or a target.edu.uci.ics.jung.graph.Graph<T,
RepastEdge<T>> getGraph()
int
getInDegree
(T agent) Gets the in degree of the node associated with the specified object.getInEdges
(T agent) Gets all the in-edges for the specified object.getName()
getNodes()
Gets an iterator over all the agent nodes in this network.int
getOutDegree
(T agent) Gets the out degree of the node associated with the specified object.getOutEdges
(T agent) Gets all the out-edges for the specified object.getPredecessors
(T agent) Gets the predecessors of the specified object.Gets all the listeners for this projection.getRandomAdjacent
(T agent) Gets a random object that is adjacent to the specified object.getRandomPredecessor
(T agent) Get a random predecessor of the specified object.getRandomSuccessor
(T agent) Gets a random successor of the specified object.getSuccessors
(T agent) Gets the successors of the specified object.int
hashCode()
boolean
isAdjacent
(T first, T second) Returns true if the first object is adjacent to the second.boolean
boolean
isPredecessor
(T first, T second) Returns true if the first object is a predecessor of the second.boolean
isSuccessor
(T first, T second) Returns true if the first object is a successor of the second.int
numEdges()
Gets the number of edges in this Network.protected void
void
removeEdge
(RepastEdge<T> edge) Removes the specified edge from this Network.void
Method removes all edges in the given network.boolean
removeProjectionListener
(ProjectionListener listener) Removes a listener from the this projection.void
removeVertex
(T vertex) void
setGraph
(edu.uci.ics.jung.graph.Graph<T, RepastEdge<T>> graph) int
size()
Gets the number of nodes in this network.toString()
-
Constructor Details
-
ContextJungNetwork
-
-
Method Details
-
eventOccured
Description copied from interface:ContextListener
Called to nofify the listener of a change to a context.- Specified by:
eventOccured
in interfaceContextListener<T>
- Parameters:
ev
- The event of which to notify the listener.
-
addAll
protected void addAll() -
removeAll
protected void removeAll() -
getEdgeCreator
Gets the EdgeCreator used to create edges for this Network.addEdge
andaddEdge
will use this creator to create edges. Any edge added withaddEdge
must be of the same type as that created with this EdgeCreator. By default, an edge creator that creates RepastEdges is used. The default EdgeCreator will create RepastEdge- Specified by:
getEdgeCreator
in interfaceNetwork<T>
- Returns:
- the edge class of this network
-
addEdge
Description copied from interface:Network
Adds the specified edge to this Network. This will change the directionality of the edge to met that of the network. -
addEdge
Description copied from interface:Network
Adds an edge between the specified objects. -
addEdge
Description copied from interface:Network
Adds an edge between the specified objects. -
addProjectionListener
Description copied from interface:Projection
Adds listener for this projection.- Specified by:
addProjectionListener
in interfaceProjection<T>
- Parameters:
listener
- the listener to add.
-
addVertex
-
equals
-
evaluate
Description copied from interface:Projection
Evaluate this Projection against the specified Predicate. This typically involves a double dispatch where the Projection calls back to the predicate, passing itself.- Specified by:
evaluate
in interfaceProjection<T>
- Returns:
- true if the predicate evaluates to true, otherwise false. False can also mean that the predicate is not applicable to this Projection. For example, a linked type predicate evaluated against a grid projection.
-
getAdjacent
Description copied from interface:Network
Gets any objects that are adjacent to this object. An object is adjacent if it has an edge either from or to the specified object.- Specified by:
getAdjacent
in interfaceNetwork<T>
- Parameters:
agent
- the object whose adjacent objects should be returned- Returns:
- an iterator over all the objects adjacent to the specified object.
-
getDegree
public int getDegree()Description copied from interface:Network
Get the total degree (number of edges) for the graph. -
getDegree
Description copied from interface:Network
Gets the degree of the node associated with the specified object. -
getEdge
Description copied from interface:Network
Retrieves the edge between the specified source and target. If multiple edges exist between these two objects, the first found will be returned. -
getEdges
Description copied from interface:Network
Gets all the edges in this Network. -
getEdges
Description copied from interface:Network
Gets all the edges where the specified object is a source or a target. -
getGraph
-
getInDegree
Description copied from interface:Network
Gets the in degree of the node associated with the specified object.- Specified by:
getInDegree
in interfaceNetwork<T>
- Parameters:
agent
- the object whose node's in degree we want.- Returns:
- the in degree of the node associated with the specified object.
-
getInEdges
Description copied from interface:Network
Gets all the in-edges for the specified object. In a directed network an in edge is any edge where the specified object is the target. In an undirected network, edges are both in- and out-, and so all edges are returned.- Specified by:
getInEdges
in interfaceNetwork<T>
- Parameters:
agent
- the object whose in-edges should be returned- Returns:
- an iterator over all the in-edges for the specified object.
-
getName
- Specified by:
getName
in interfaceProjection<T>
-
getNodes
Description copied from interface:Network
Gets an iterator over all the agent nodes in this network. -
getOutDegree
Description copied from interface:Network
Gets the out degree of the node associated with the specified object.- Specified by:
getOutDegree
in interfaceNetwork<T>
- Parameters:
agent
- the object whose node's out degree we want.- Returns:
- the out degree of the node associated with the specified object.
-
getOutEdges
Description copied from interface:Network
Gets all the out-edges for the specified object. In a directed network an out edge is any edge where the specified object is the source. In an undirected network, edges are both in- and out-, and so all edges are returned.- Specified by:
getOutEdges
in interfaceNetwork<T>
- Parameters:
agent
- the object whose out-edges should be returned- Returns:
- an iterator over all the out-edges for the specified object.
-
getPredecessors
Description copied from interface:Network
Gets the predecessors of the specified object. If the network is directed then the predecessors are any objects connected to the specified object by an edge where the specified object is the target of that edge. If the network is undirected, then this returns any object connected to the specified object.- Specified by:
getPredecessors
in interfaceNetwork<T>
- Parameters:
agent
- the object whose predecessors should be returned- Returns:
- an iterator over the predecessors of the specified object.
-
getProjectionListeners
Description copied from interface:Projection
Gets all the listeners for this projection.- Specified by:
getProjectionListeners
in interfaceProjection<T>
- Returns:
- an iterable over all the listeners for this projection.
-
getRandomAdjacent
Description copied from interface:Network
Gets a random object that is adjacent to the specified object.- Specified by:
getRandomAdjacent
in interfaceNetwork<T>
- Returns:
- a random object that is adjacent to the specified object or null if no objects are adjacent.
-
getRandomPredecessor
Description copied from interface:Network
Get a random predecessor of the specified object. If the network is directed then the predecessors are any objects connected to the specified object by an edge where the specified object is the target of that edge. If the network is undirected, then a predecessor can be any object connected to the specified object.- Specified by:
getRandomPredecessor
in interfaceNetwork<T>
- Returns:
- a random predecessor of the specified object or null if there are no predecessors.
-
getRandomSuccessor
Description copied from interface:Network
Gets a random successor of the specified object. If the network is directed then the successors are any objects connected to the specified object by an edge where the specified object is the source of that edge. If the network is undirected, then a successor can be any object connected to the specified object.- Specified by:
getRandomSuccessor
in interfaceNetwork<T>
- Returns:
- a random predecessor of the specified object or null if there are no successors.
-
getSuccessors
Description copied from interface:Network
Gets the successors of the specified object. If the network is directed then the successors are any objects connected to the specified object by an edge where the specified object is the source of that edge. If the network is undirected, then this returns any object connected to the specified object.- Specified by:
getSuccessors
in interfaceNetwork<T>
- Parameters:
agent
- the object whose successors should be returned- Returns:
- an iterator over the successors of the specified object.
-
hashCode
public int hashCode() -
isAdjacent
Description copied from interface:Network
Returns true if the first object is adjacent to the second. An object is adjacent to another if there is an edge between the first object and the second, regardeless of the edges directionality.- Specified by:
isAdjacent
in interfaceNetwork<T>
- Returns:
- true if the first object is a adjacent to the second.
-
isDirected
public boolean isDirected()- Specified by:
isDirected
in interfaceNetwork<T>
- Returns:
- true if this Network is directed, otherwise false.
-
isPredecessor
Description copied from interface:Network
Returns true if the first object is a predecessor of the second. If the network is directed then the predecessors are any objects connected to the specified object by an edge where the specified object is the target of that edge. If the network is undirected, then a predecessor can be any object connected to the specified object.- Specified by:
isPredecessor
in interfaceNetwork<T>
- Returns:
- true if the first object is a predecessor of the second.
-
isSuccessor
Description copied from interface:Network
Returns true if the first object is a successor of the second. If the network is directed then the successors are any objects connected to the specified object by an edge where the specified object is the source of that edge. If the network is undirected, then a successor can be any object connected to the specified object.- Specified by:
isSuccessor
in interfaceNetwork<T>
- Returns:
- true if the first object is a successor of the second.
-
numEdges
public int numEdges()Description copied from interface:Network
Gets the number of edges in this Network. -
removeEdge
Description copied from interface:Network
Removes the specified edge from this Network.- Specified by:
removeEdge
in interfaceNetwork<T>
- Parameters:
edge
- the edge to remove
-
containsEdge
Returns whether or not this network contains the specified edge.- Specified by:
containsEdge
in interfaceNetwork<T>
- Parameters:
edge
- the edge to check- Returns:
- true if the network contains the specified edge, otherwise false.
-
removeProjectionListener
Description copied from interface:Projection
Removes a listener from the this projection.- Specified by:
removeProjectionListener
in interfaceProjection<T>
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was succesfully removed, otherwise false
-
removeVertex
-
setGraph
-
size
public int size()Description copied from interface:Network
Gets the number of nodes in this network. -
toString
-
removeEdges
public void removeEdges()Description copied from interface:Network
Method removes all edges in the given network.- Specified by:
removeEdges
in interfaceNetwork<T>
-