Example #1
0
  /**
   * This method recursively walks the network, looking for connected substations
   *
   * @param current_node The node that the walker is currently at
   * @param substations A set of found and connected substations
   * @param visited_nodes A set of all the nodes that have been visited
   */
  private void searchForConnectedSubStations(
      PowerGridNode current_node,
      Set<PowerGridNode> substations,
      Set<PowerGridNode> visited_nodes) {
    if (current_node.isSubStation()) substations.add(current_node);

    visited_nodes.add(current_node);

    for (PowerGridNode neighbour : current_node.getNeighbours()) {
      if (visited_nodes.contains(neighbour)) continue;

      searchForConnectedSubStations(neighbour, substations, visited_nodes);
    }
  }