Package repast.simphony.space.graph
Interface Network<T>
- All Superinterfaces:
Projection<T>
- All Known Implementing Classes:
ContextJungNetwork
,DirectedJungNetwork
,JungNetwork
,UndirectedJungNetwork
Interface for Network projections.
- Version:
- $Revision$ $Date$
- Author:
- Nick Collier
-
Method Summary
Modifier and TypeMethodDescriptionaddEdge
(RepastEdge<T> edge) Adds the specified edge to this Network.Adds an edge between the specified objects.Adds an edge between the specified objects.boolean
containsEdge
(RepastEdge<T> edge) Returns whether or not this network contains the specified edge.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.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
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.int
size()
Gets the number of nodes in this network.Methods inherited from interface repast.simphony.space.projection.Projection
addProjectionListener, evaluate, getName, getProjectionListeners, removeProjectionListener
-
Method Details
-
isDirected
boolean isDirected()- Returns:
- true if this Network is directed, otherwise false.
-
getEdgeCreator
EdgeCreator<? extends RepastEdge<T>,T> 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- Returns:
- the edge class of this network
-
addEdge
Adds an edge between the specified objects.- Parameters:
source
- the source objecttarget
- the target object- Returns:
- the created edge.
-
addEdge
Adds an edge between the specified objects.- Parameters:
source
- the source objecttarget
- the target objectweight
- weight of the new edge- Returns:
- the created edge.
-
addEdge
Adds the specified edge to this Network. This will change the directionality of the edge to met that of the network.- Parameters:
edge
- the edge to add.- Returns:
- the added edge.
-
getEdge
Retrieves the edge between the specified source and target. If multiple edges exist between these two objects, the first found will be returned.- Parameters:
source
- the source of the edgetarget
- the target of the edge- Returns:
- an edge or null if no such edge exists
-
removeEdge
Removes the specified edge from this Network.- Parameters:
edge
- the edge to remove
-
containsEdge
Returns whether or not this network contains the specified edge.- Parameters:
edge
- the edge to check- Returns:
- true if the network contains the specified edge, otherwise false.
-
size
int size()Gets the number of nodes in this network.- Returns:
- the number of nodes in this network.
-
numEdges
int numEdges()Gets the number of edges in this Network.- Returns:
- the number of edges in this Network.
-
getPredecessors
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.- Parameters:
agent
- the object whose predecessors should be returned- Returns:
- an iterator over the predecessors of the specified object.
-
getSuccessors
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.- Parameters:
agent
- the object whose successors should be returned- Returns:
- an iterator over the successors of the specified object.
-
getAdjacent
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.- Parameters:
agent
- the object whose adjacent objects should be returned- Returns:
- an iterator over all the objects adjacent to the specified object.
-
getRandomPredecessor
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.- Parameters:
agent
-- Returns:
- a random predecessor of the specified object or null if there are no predecessors.
-
getRandomSuccessor
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.- Parameters:
agent
-- Returns:
- a random predecessor of the specified object or null if there are no successors.
-
getRandomAdjacent
Gets a random object that is adjacent to the specified object.- Parameters:
agent
-- Returns:
- a random object that is adjacent to the specified object or null if no objects are adjacent.
-
isPredecessor
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.- Parameters:
first
-second
-- Returns:
- true if the first object is a predecessor of the second.
-
isSuccessor
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.- Parameters:
first
-second
-- Returns:
- true if the first object is a successor of the second.
-
isAdjacent
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.- Parameters:
first
-second
-- Returns:
- true if the first object is a adjacent to the second.
-
getDegree
Gets the degree of the node associated with the specified object.- Parameters:
agent
- the object whose node's degree we want.- Returns:
- the degree of the node associated with the specified object.
-
getInEdges
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.- Parameters:
agent
- the object whose in-edges should be returned- Returns:
- an iterator over all the in-edges for the specified object.
-
getOutEdges
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.- Parameters:
agent
- the object whose out-edges should be returned- Returns:
- an iterator over all the out-edges for the specified object.
-
getEdges
Gets all the edges where the specified object is a source or a target.- Parameters:
agent
- the object whose edges should be returned- Returns:
- an iterator over all the edges where the specified object is a source or a target.
-
getEdges
Iterable<RepastEdge<T>> getEdges()Gets all the edges in this Network.- Returns:
- an iterator over all the edges in this Network.
-
getNodes
Gets an iterator over all the agent nodes in this network.- Returns:
- an iterator over all the agent nodes in this network.
-
getInDegree
Gets the in degree of the node associated with the specified object.- Parameters:
agent
- the object whose node's in degree we want.- Returns:
- the in degree of the node associated with the specified object.
-
getOutDegree
Gets the out degree of the node associated with the specified object.- Parameters:
agent
- the object whose node's out degree we want.- Returns:
- the out degree of the node associated with the specified object.
-
getDegree
int getDegree()Get the total degree (number of edges) for the graph.- Returns:
- the total degree (number of edges) for the graph.
-
removeEdges
void removeEdges()Method removes all edges in the given network.
-