Package casa.lepton

Class OppNetFullyConnected

java.lang.Object
casa.lepton.OppNetFullyConnected
All Implemented Interfaces:
OppNet, OppNetEventsSource

public class OppNetFullyConnected extends Object implements OppNet
A fully connected opportunistic network: all pairs of nodes are linked together, provided both nodes are online.
  • Constructor Details

    • OppNetFullyConnected

      public OppNetFullyConnected()
  • Method Details

    • addNode

      public void addNode(String nodeId, String profile)
      Description copied from interface: OppNet
      Add a new node in the OppNet.
      Specified by:
      addNode in interface OppNet
      Parameters:
      nodeId - the new node id.
      profile - the node's profile name (may be null)
    • deleteNode

      public void deleteNode(String nodeId)
      Description copied from interface: OppNet
      Remove a node from the OppNet.
      Specified by:
      deleteNode in interface OppNet
      Parameters:
      nodeId - the id of the node to be deleted.
    • isNode

      public boolean isNode(String nodeId)
      Description copied from interface: OppNet
      Check whether the node exists in the OppNet.
      Specified by:
      isNode in interface OppNet
      Parameters:
      nodeId - a node id.
      Returns:
      true if a node having this node id exists in the graph.
    • getNodes

      public Collection<String> getNodes()
      Description copied from interface: OppNet
      Give the nodes in the OppNet.
      Specified by:
      getNodes in interface OppNet
      Returns:
      a collection of all nodes in the graph.
    • setOnline

      public void setOnline(String nodeId, boolean online)
      Description copied from interface: OppNet
      Change the on/offline status of the node and update edges accordingly.
      Specified by:
      setOnline in interface OppNet
      Parameters:
      nodeId - a node id.
      online - the new status for the node having this id.
    • isOnline

      public boolean isOnline(String nodeId)
      Description copied from interface: OppNet
      Give the on/offline status of the node.
      Specified by:
      isOnline in interface OppNet
      Parameters:
      nodeId - a node id.
      Returns:
      the status of the node having this id.
    • setLabel

      public void setLabel(String nodeId, String label)
      Description copied from interface: OppNet
      Change the label of the node
      Specified by:
      setLabel in interface OppNet
      Parameters:
      nodeId - a node id.
      label - the new label for the node having this id.
    • getLabel

      public String getLabel(String nodeId)
      Description copied from interface: OppNet
      Give the label of the node
      Specified by:
      getLabel in interface OppNet
      Parameters:
      nodeId - a node id.
      Returns:
      the label for the node having this id.
    • setTag

      public void setTag(String nodeId, String tag)
      Description copied from interface: OppNet
      Set the given tag to the node.
      Specified by:
      setTag in interface OppNet
      Parameters:
      nodeId - a node id.
      tag - the new status for the node having this id.
    • getTag

      public String getTag(String nodeId)
      Description copied from interface: OppNet
      Give the tag of the node.
      Specified by:
      getTag in interface OppNet
      Parameters:
      nodeId - a node id.
      Returns:
      the tag of the node having this id.
    • addConnectivityType

      public void addConnectivityType(String nodeId, String connectivityType)
      Description copied from interface: OppNet
      Add a new connectivity type for the node and update edges accordingly.
      Specified by:
      addConnectivityType in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type to be added to this node.
    • removeConnectivityType

      public void removeConnectivityType(String nodeId, String connectivityType)
      Description copied from interface: OppNet
      Remove a connectivity type for the node and update edges accordingly.
      Specified by:
      removeConnectivityType in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type to be removed from this node.
    • setNodeStatus

      public void setNodeStatus(String nodeId, String connectivityType, String status)
      Description copied from interface: OppNet
      Change the status of a node for a given connectivity type.
      Specified by:
      setNodeStatus in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type.
      status - the new status.
    • getNodeStatus

      public String getNodeStatus(String nodeId, String connectivityType)
      Description copied from interface: OppNet
      Give the status of a node for a given connectivity type.
      Specified by:
      getNodeStatus in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type.
      Returns:
      the status for this node and connectivity type.
    • setEdgeStatus

      public boolean setEdgeStatus(String nodeId1, String nodeId2, String connectivityType, String status)
      Description copied from interface: OppNet
      Change the status of an edge charaterized by the nodes' ids and the connectivity type. If the edge does not exist, do nothing and change the status of nodes accordingly.
      Specified by:
      setEdgeStatus in interface OppNet
      Parameters:
      nodeId1 - a node id.
      nodeId2 - another node id.
      connectivityType - a connectivity type.
      status - the new edge status.
      Returns:
      true if the status has been changed.
    • getEdgeStatus

      public String getEdgeStatus(String nodeId1, String nodeId2, String connectivityType)
      Description copied from interface: OppNet
      Give the status of an edge charaterized by the nodes' ids and the connectivity type. If the edge does not exist, return null
      Specified by:
      getEdgeStatus in interface OppNet
      Parameters:
      nodeId1 - a node id.
      nodeId2 - another node id.
      connectivityType - a connectivity type.
      Returns:
      the edge status
    • getNeighbors

      public Collection<String> getNeighbors(String nodeId, String connectivityType, String edgeStatus)
      Description copied from interface: OppNet
      Give the neighbors' ids of the node for a given connectivity type and status. If connectivityType is null, give all neighbors for any connectivity type. If status is null, give all neighbors for any status.
      Specified by:
      getNeighbors in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type. May be null.
      edgeStatus - an edge status. May be null.
      Returns:
      ids of nodes having edges with the given status and connectivity type.
    • nbNeighbors

      public int nbNeighbors(String nodeId, String connectivityType, String edgeStatus)
      Description copied from interface: OppNet
      Returns the number of neighbors of the node for the given connectivity type and status. If connectivityType is null, returns the number of neighbors for any connectivity type. If status is null, returns the number of neighbors whatever the connectivity status.
      Specified by:
      nbNeighbors in interface OppNet
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type. May be null.
      edgeStatus - an edge status. May be null.
      Returns:
      return true if the nodes have an edge having the given status and connectivity type.
    • areNeighbors

      public boolean areNeighbors(String nodeId1, String nodeId2, String connectivityType, String edgeStatus)
      Description copied from interface: OppNet
      Returns true if there is an edge with the node for the given connectivity type and status. If connectivityType is null, return true if there is an edge for any connectivity type. If status is null, give all neighbors for any status.
      Specified by:
      areNeighbors in interface OppNet
      Parameters:
      nodeId1 - a node id.
      nodeId2 - another node id.
      connectivityType - a connectivity type. May be null.
      edgeStatus - an edge status. May be null.
      Returns:
      return true if the nodes have an edge having the given status and connectivity type.
    • makeEdgeId

      public String makeEdgeId(String node1, String node2, String connectivityType)
      Description copied from interface: OppNet
      Give a unique edge id from the given nodes ids and connectivityType in the form "idA-idB:type" where idA = min(id1,id2) and idB = max(id1,id2).
      Specified by:
      makeEdgeId in interface OppNet
      Parameters:
      node1 - a node id.
      node2 - other node id.
      connectivityType - the connectivity type.
      Returns:
      unique edge id.
    • addEdgeListener

      public void addEdgeListener(String nodeId, String connectivityType, OppEdgeListener listener)
      Description copied from interface: OppNetEventsSource
      Add a new listener interested in edge events for the given node.
      Specified by:
      addEdgeListener in interface OppNetEventsSource
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type.
      listener - the new listener.
    • removeEdgeListener

      public void removeEdgeListener(String nodeId, String connectivityType)
      Description copied from interface: OppNetEventsSource
      Remove a listener interested in edge events for the given node.
      Specified by:
      removeEdgeListener in interface OppNetEventsSource
      Parameters:
      nodeId - a node id.
      connectivityType - a connectivity type.
    • addNodeListener

      public void addNodeListener(String nodeId, OppNodeListener listener)
      Description copied from interface: OppNetEventsSource
      Add a new listener interested in node events for a specific node.
      Specified by:
      addNodeListener in interface OppNetEventsSource
      Parameters:
      nodeId - a node id.
      listener - the new listener.
    • removeNodeListener

      public void removeNodeListener(String nodeId)
      Description copied from interface: OppNetEventsSource
      Remove a listener interested in node events.
      Specified by:
      removeNodeListener in interface OppNetEventsSource
      Parameters:
      nodeId - a node id.