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
FieldsModifier 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
ConstructorsConstructorDescriptionJungNetwork(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.voidbooleancontainsEdge(RepastEdge<T> edge) Returns whether or not this network contains the specified edge.booleanevaluate(ProjectionPredicate predicate) Evaluate this Projection against the specified Predicate.getAdjacent(T agent) Gets any objects that are adjacent to this object.intGet the total degree (number of edges) for the graph.intGets 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()intgetInDegree(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.intgetOutDegree(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.booleanisAdjacent(T first, T second) Returns true if the first object is adjacent to the second.booleanisPredecessor(T first, T second) Returns true if the first object is a predecessor of the second.booleanisSuccessor(T first, T second) Returns true if the first object is a successor of the second.intnumEdges()Gets the number of edges in this Network.voidremoveEdge(RepastEdge<T> edge) Removes the specified edge from this Network.voidMethod removes all edges in the given network.voidremoveVertex(T vertex) voidsetGraph(edu.uci.ics.jung.graph.Graph<T, RepastEdge<T>> graph) intsize()Gets the number of nodes in this network.Methods inherited from class repast.simphony.space.projection.DefaultProjection
addProjectionListener, fireProjectionEvent, getName, getProjectionListeners, removeProjectionListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface repast.simphony.space.graph.Network
addEdge, isDirectedMethods 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.addEdgeandaddEdgewill use this creator to create edges. Any edge added withaddEdgemust 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:
getEdgeCreatorin interfaceNetwork<T>- Returns:
- the edge class of this network
-
setGraph
-
getGraph
-
evaluate
Description copied from class:DefaultProjectionEvaluate this Projection against the specified Predicate. This typically involves a double dispatch where the Projection calls back to the predicate, passing itself.- Specified by:
evaluatein interfaceProjection<T>- Overrides:
evaluatein 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:NetworkGets 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:
getAdjacentin 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:NetworkGet the total degree (number of edges) for the graph. -
getDegree
Description copied from interface:NetworkGets the degree of the node associated with the specified object. -
getEdges
Description copied from interface:NetworkGets all the edges in this Network. -
getEdges
Description copied from interface:NetworkGets all the edges where the specified object is a source or a target. -
getInDegree
Description copied from interface:NetworkGets the in degree of the node associated with the specified object.- Specified by:
getInDegreein 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:NetworkGets 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:
getInEdgesin 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:NetworkGets an iterator over all the agent nodes in this network. -
getOutDegree
Description copied from interface:NetworkGets the out degree of the node associated with the specified object.- Specified by:
getOutDegreein 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:NetworkGets 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:
getOutEdgesin 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:NetworkGets 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:
getPredecessorsin 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:NetworkGets a random object that is adjacent to the specified object.- Specified by:
getRandomAdjacentin 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:NetworkGet 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:
getRandomPredecessorin interfaceNetwork<T>- Returns:
- a random predecessor of the specified object or null if there are no predecessors.
-
getRandomSuccessor
Description copied from interface:NetworkGets 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:
getRandomSuccessorin interfaceNetwork<T>- Returns:
- a random predecessor of the specified object or null if there are no successors.
-
getSuccessors
Description copied from interface:NetworkGets 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:
getSuccessorsin 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:NetworkReturns 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:
isAdjacentin interfaceNetwork<T>- Returns:
- true if the first object is a adjacent to the second.
-
isPredecessor
Description copied from interface:NetworkReturns 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:
isPredecessorin interfaceNetwork<T>- Returns:
- true if the first object is a predecessor of the second.
-
isSuccessor
Description copied from interface:NetworkReturns 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:
isSuccessorin interfaceNetwork<T>- Returns:
- true if the first object is a successor of the second.
-
numEdges
public int numEdges()Description copied from interface:NetworkGets the number of edges in this Network. -
removeEdge
Description copied from interface:NetworkRemoves the specified edge from this Network.- Specified by:
removeEdgein interfaceNetwork<T>- Parameters:
edge- the edge to remove
-
containsEdge
Returns whether or not this network contains the specified edge.- Specified by:
containsEdgein interfaceNetwork<T>- Parameters:
edge- the edge to check- Returns:
- true if the network contains the specified edge, otherwise false.
-
addEdge
Description copied from interface:NetworkAdds 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:NetworkAdds an edge between the specified objects. -
getEdge
Description copied from interface:NetworkRetrieves 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:NetworkGets the number of nodes in this network. -
addVertex
-
removeVertex
-
removeEdges
public void removeEdges()Description copied from interface:NetworkMethod removes all edges in the given network.- Specified by:
removeEdgesin interfaceNetwork<T>
-