Creating cluster of Fog devices. Here two fog devices, residing in the same level and connected with identical upper level Fog nodes, if located at a threshold distance, they are considered belonging to the same Fog cluster.
static Map
static Map List private void formClusters() { for(FogDevice fd: getFogDevices()){ clusterInfo.put(fd.getId(), -1); } int clusterId = 0; for(int i=0;i FogDevice fd1 = getFogDevices().get(i); for(int j=0;j FogDevice fd2 = getFogDevices().get(j); if(fd1.getId()!=fd2.getId()&& fd1.getParen- tId()==fd2.getParentId() &&calculateDistance(fd1, fd2) TER_DISTANCE && fd1.getLevel()==fd2.getLevel()) { int fd1ClusteriD = clusterInfo.get(fd1.getId()); int fd2ClusteriD = clusterInfo.get(fd2.getId()); if(fd1ClusteriD==-1 && fd2ClusteriD==-1){ clusterId++; clusterInfo.put(fd1.getId(), clusterId); clusterInfo.put(fd2.getId(), clusterId); } else if(fd1ClusteriD==-1) clusterInfo.put(fd1.getId(), cluster- Info.get(fd2.getId())); else if(fd2ClusteriD==-1) clusterInfo.put(fd2.getId(), cluster- Info.get(fd1.getId())); } } } for(int id:clusterInfo.keySet()){ if(!clusters.containsKey(clusterInfo.get(id))){ List ger>(); clusterMembers.add(id); clusters.put(clusterInfo.get(id), clusterMembers); } else { List Info.get(id)); clusterMembers.add(id); clusters.put(clusterInfo.get(id), clusterMembers); } } for(int id:clusters.keySet()) System.out.println(id+" "+clusters.get(id)); } Inclusion in Controller constructor method: formClusters(); Config Class: public static final double CLUSTER_DISTANCE = 2.00;