Class ContextJungNetwork<T>

java.lang.Object
repast.simphony.context.space.graph.ContextJungNetwork<T>
All Implemented Interfaces:
ContextListener<T>, Network<T>, Projection<T>

public class ContextJungNetwork<T> extends Object implements Network<T>, ContextListener<T>
  • Constructor Details

  • Method Details

    • eventOccured

      public void eventOccured(ContextEvent<T> ev)
      Description copied from interface: ContextListener
      Called to nofify the listener of a change to a context.
      Specified by:
      eventOccured in interface ContextListener<T>
      Parameters:
      ev - The event of which to notify the listener.
    • addAll

      protected void addAll()
    • removeAll

      protected void removeAll()
    • getEdgeCreator

      public EdgeCreator<? extends RepastEdge<T>,T> getEdgeCreator()
      Gets the EdgeCreator used to create edges for this Network. addEdge and addEdge will use this creator to create edges. Any edge added with addEdge 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 interface Network<T>
      Returns:
      the edge class of this network
    • addEdge

      public RepastEdge<T> addEdge(RepastEdge<T> edge)
      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.
      Specified by:
      addEdge in interface Network<T>
      Parameters:
      edge - the edge to add.
      Returns:
      the added edge.
    • addEdge

      public RepastEdge<T> addEdge(T source, T target, double weight)
      Description copied from interface: Network
      Adds an edge between the specified objects.
      Specified by:
      addEdge in interface Network<T>
      Parameters:
      source - the source object
      target - the target object
      weight - weight of the new edge
      Returns:
      the created edge.
    • addEdge

      public RepastEdge<T> addEdge(T source, T target)
      Description copied from interface: Network
      Adds an edge between the specified objects.
      Specified by:
      addEdge in interface Network<T>
      Parameters:
      source - the source object
      target - the target object
      Returns:
      the created edge.
    • addProjectionListener

      public void addProjectionListener(ProjectionListener listener)
      Description copied from interface: Projection
      Adds listener for this projection.
      Specified by:
      addProjectionListener in interface Projection<T>
      Parameters:
      listener - the listener to add.
    • addVertex

      public void addVertex(T vertex)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • evaluate

      public boolean evaluate(ProjectionPredicate predicate)
      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 interface Projection<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

      public Iterable<T> getAdjacent(T agent)
      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 interface Network<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.
      Specified by:
      getDegree in interface Network<T>
      Returns:
      the total degree (number of edges) for the graph.
    • getDegree

      public int getDegree(T agent)
      Description copied from interface: Network
      Gets the degree of the node associated with the specified object.
      Specified by:
      getDegree in interface Network<T>
      Parameters:
      agent - the object whose node's degree we want.
      Returns:
      the degree of the node associated with the specified object.
    • getEdge

      public RepastEdge<T> getEdge(T source, T target)
      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.
      Specified by:
      getEdge in interface Network<T>
      Parameters:
      source - the source of the edge
      target - the target of the edge
      Returns:
      an edge or null if no such edge exists
    • getEdges

      public Iterable<RepastEdge<T>> getEdges()
      Description copied from interface: Network
      Gets all the edges in this Network.
      Specified by:
      getEdges in interface Network<T>
      Returns:
      an iterator over all the edges in this Network.
    • getEdges

      public Iterable<RepastEdge<T>> getEdges(T agent)
      Description copied from interface: Network
      Gets all the edges where the specified object is a source or a target.
      Specified by:
      getEdges in interface Network<T>
      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.
    • getGraph

      public edu.uci.ics.jung.graph.Graph<T,RepastEdge<T>> getGraph()
    • getInDegree

      public int getInDegree(T agent)
      Description copied from interface: Network
      Gets the in degree of the node associated with the specified object.
      Specified by:
      getInDegree in interface Network<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

      public Iterable<RepastEdge<T>> getInEdges(T agent)
      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 interface Network<T>
      Parameters:
      agent - the object whose in-edges should be returned
      Returns:
      an iterator over all the in-edges for the specified object.
    • getName

      public String getName()
      Specified by:
      getName in interface Projection<T>
    • getNodes

      public Iterable<T> getNodes()
      Description copied from interface: Network
      Gets an iterator over all the agent nodes in this network.
      Specified by:
      getNodes in interface Network<T>
      Returns:
      an iterator over all the agent nodes in this network.
    • getOutDegree

      public int getOutDegree(T agent)
      Description copied from interface: Network
      Gets the out degree of the node associated with the specified object.
      Specified by:
      getOutDegree in interface Network<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

      public Iterable<RepastEdge<T>> getOutEdges(T agent)
      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 interface Network<T>
      Parameters:
      agent - the object whose out-edges should be returned
      Returns:
      an iterator over all the out-edges for the specified object.
    • getPredecessors

      public Iterable<T> getPredecessors(T agent)
      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 interface Network<T>
      Parameters:
      agent - the object whose predecessors should be returned
      Returns:
      an iterator over the predecessors of the specified object.
    • getProjectionListeners

      public Collection<ProjectionListener> getProjectionListeners()
      Description copied from interface: Projection
      Gets all the listeners for this projection.
      Specified by:
      getProjectionListeners in interface Projection<T>
      Returns:
      an iterable over all the listeners for this projection.
    • getRandomAdjacent

      public T getRandomAdjacent(T agent)
      Description copied from interface: Network
      Gets a random object that is adjacent to the specified object.
      Specified by:
      getRandomAdjacent in interface Network<T>
      Returns:
      a random object that is adjacent to the specified object or null if no objects are adjacent.
    • getRandomPredecessor

      public T getRandomPredecessor(T agent)
      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 interface Network<T>
      Returns:
      a random predecessor of the specified object or null if there are no predecessors.
    • getRandomSuccessor

      public T getRandomSuccessor(T agent)
      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 interface Network<T>
      Returns:
      a random predecessor of the specified object or null if there are no successors.
    • getSuccessors

      public Iterable<T> getSuccessors(T agent)
      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 interface Network<T>
      Parameters:
      agent - the object whose successors should be returned
      Returns:
      an iterator over the successors of the specified object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isAdjacent

      public boolean isAdjacent(T first, T second)
      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 interface Network<T>
      Returns:
      true if the first object is a adjacent to the second.
    • isDirected

      public boolean isDirected()
      Specified by:
      isDirected in interface Network<T>
      Returns:
      true if this Network is directed, otherwise false.
    • isPredecessor

      public boolean isPredecessor(T first, T second)
      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 interface Network<T>
      Returns:
      true if the first object is a predecessor of the second.
    • isSuccessor

      public boolean isSuccessor(T first, T second)
      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 interface Network<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.
      Specified by:
      numEdges in interface Network<T>
      Returns:
      the number of edges in this Network.
    • removeEdge

      public void removeEdge(RepastEdge<T> edge)
      Description copied from interface: Network
      Removes the specified edge from this Network.
      Specified by:
      removeEdge in interface Network<T>
      Parameters:
      edge - the edge to remove
    • containsEdge

      public boolean containsEdge(RepastEdge<T> edge)
      Returns whether or not this network contains the specified edge.
      Specified by:
      containsEdge in interface Network<T>
      Parameters:
      edge - the edge to check
      Returns:
      true if the network contains the specified edge, otherwise false.
    • removeProjectionListener

      public boolean removeProjectionListener(ProjectionListener listener)
      Description copied from interface: Projection
      Removes a listener from the this projection.
      Specified by:
      removeProjectionListener in interface Projection<T>
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was succesfully removed, otherwise false
    • removeVertex

      public void removeVertex(T vertex)
    • setGraph

      public void setGraph(edu.uci.ics.jung.graph.Graph<T,RepastEdge<T>> graph)
    • size

      public int size()
      Description copied from interface: Network
      Gets the number of nodes in this network.
      Specified by:
      size in interface Network<T>
      Returns:
      the number of nodes in this network.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • removeEdges

      public void removeEdges()
      Description copied from interface: Network
      Method removes all edges in the given network.
      Specified by:
      removeEdges in interface Network<T>