Package repast.simphony.space.graph
Class JungNetwork<T>
java.lang.Object
repast.simphony.space.projection.DefaultProjection<T>
repast.simphony.space.graph.JungNetwork<T>
- All Implemented Interfaces:
Network<T>
,Projection<T>
- Direct Known Subclasses:
DirectedJungNetwork
,UndirectedJungNetwork
-
Field Summary
Modifier and TypeFieldDescriptionprotected EdgeCreator<? extends RepastEdge<T>,
T> protected edu.uci.ics.jung.graph.Graph<T,
RepastEdge<T>> Fields inherited from class repast.simphony.space.projection.DefaultProjection
listeners, name
-
Constructor Summary
ConstructorDescriptionJungNetwork
(String name) JungNetwork
(String name, EdgeCreator<? extends RepastEdge<T>, T> creator) -
Method Summary
Modifier and TypeMethodDescriptionaddEdge
(RepastEdge<T> edge) Adds the specified edge to this Network.addEdge
(RepastEdge<T> edge, edu.uci.ics.jung.graph.util.EdgeType type) Adds an edge between the specified objects.void
boolean
containsEdge
(RepastEdge<T> edge) Returns whether or not this network contains the specified edge.boolean
evaluate
(ProjectionPredicate predicate) Evaluate this Projection against the specified Predicate.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.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.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.boolean
isAdjacent
(T first, T second) Returns true if the first object is adjacent to the second.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.void
removeEdge
(RepastEdge<T> edge) Removes the specified edge from this Network.void
Method removes all edges in the given network.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.Methods inherited from class repast.simphony.space.projection.DefaultProjection
addProjectionListener, fireProjectionEvent, getName, getProjectionListeners, removeProjectionListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface repast.simphony.space.graph.Network
addEdge, isDirected
Methods inherited from interface repast.simphony.space.projection.Projection
addProjectionListener, getName, getProjectionListeners, removeProjectionListener
-
Field Details
-
graph
-
creator
-
-
Constructor Details
-
JungNetwork
-
JungNetwork
-
-
Method Details
-
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
-
setGraph
-
getGraph
-
evaluate
Description copied from class:DefaultProjection
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>
- Overrides:
evaluate
in classDefaultProjection<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. -
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. -
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.
-
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.
-
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.
-
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.
-
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.
-
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
-
addEdge
Description copied from interface:Network
Adds an edge between the specified objects. -
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. -
size
public int size()Description copied from interface:Network
Gets the number of nodes in this network. -
addVertex
-
removeVertex
-
removeEdges
public void removeEdges()Description copied from interface:Network
Method removes all edges in the given network.- Specified by:
removeEdges
in interfaceNetwork<T>
-