Class Network


public class Network extends Object
  • Constructor Details

    • Network

      public Network(Scanner readNodes, double radius)
      Constructs and initializes a network of nodes from a txt file. Every node is stored with its position and neighbours based on the radius.
      Parameters:
      readNodes - the scanner that reads the network txt file.
      radius - the distance that the node can reach its neighbours.
  • Method Details

    • getNode

      public Node getNode(Position position)
      Returns a node based on its position.
      Parameters:
      position - the position of the node that will be returned.
      Returns:
      the node in the position.
    • getRandomNode

      public Node getRandomNode()
      Returns a random node in the network.
      Returns:
      a random node in the network.
    • getAllNodes

      public Node[] getAllNodes()
      Returns all the nodes in the network as an array.
      Returns:
      all the nodes as an array.
    • getTime

      public int getTime()
      Returns the current time.
      Returns:
      the time.
    • updateTime

      public void updateTime()
      Updates the time 1 time unit.
    • generateId

      public String generateId()
      Returns a unique id string.
      Returns:
      an id string.