Interface Network<T>

All Superinterfaces:
Projection<T>
All Known Implementing Classes:
ContextJungNetwork, DirectedJungNetwork, JungNetwork, UndirectedJungNetwork

public interface Network<T> extends Projection<T>
Interface for Network projections.
Version:
$Revision$ $Date$
Author:
Nick Collier
  • 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 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

      Returns:
      the edge class of this network
    • addEdge

      RepastEdge<T> addEdge(T source, T target)
      Adds an edge between the specified objects.
      Parameters:
      source - the source object
      target - the target object
      Returns:
      the created edge.
    • addEdge

      RepastEdge<T> addEdge(T source, T target, double weight)
      Adds an edge between the specified objects.
      Parameters:
      source - the source object
      target - the target object
      weight - weight of the new edge
      Returns:
      the created edge.
    • addEdge

      RepastEdge<T> addEdge(RepastEdge<T> edge)
      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

      RepastEdge<T> getEdge(T source, T target)
      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 edge
      target - the target of the edge
      Returns:
      an edge or null if no such edge exists
    • removeEdge

      void removeEdge(RepastEdge<T> edge)
      Removes the specified edge from this Network.
      Parameters:
      edge - the edge to remove
    • containsEdge

      boolean containsEdge(RepastEdge<T> edge)
      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

      Iterable<T> getPredecessors(T agent)
      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

      Iterable<T> getSuccessors(T agent)
      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

      Iterable<T> getAdjacent(T agent)
      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

      T getRandomPredecessor(T agent)
      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

      T getRandomSuccessor(T agent)
      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

      T getRandomAdjacent(T agent)
      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

      boolean isPredecessor(T first, T second)
      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

      boolean isSuccessor(T first, T second)
      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

      boolean isAdjacent(T first, T second)
      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

      int getDegree(T agent)
      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

      Iterable<RepastEdge<T>> getInEdges(T agent)
      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

      Iterable<RepastEdge<T>> getOutEdges(T agent)
      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

      Iterable<RepastEdge<T>> getEdges(T agent)
      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

      Iterable<T> getNodes()
      Gets an iterator over all the agent nodes in this network.
      Returns:
      an iterator over all the agent nodes in this network.
    • getInDegree

      int getInDegree(T agent)
      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

      int getOutDegree(T agent)
      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.