package vnsim.socialNet; import java.io.File; import java.io.FileInputStream; import java.io.ObjectInputStream; import java.util.ArrayList; import vnsim.map.object.Globals; import vnsim.map.object.Map; import vnsim.map.object.Point; import vnsim.map.object.Road; import vnsim.vehicular.scenarios.Route; import vnsim.vehicular.routePlan.*; public class Util { public static void getCellSize(String nume){ try { ObjectInputStream ois=new ObjectInputStream(new FileInputStream(System.getProperty("user.home") + File.separatorChar + "maps" + File.separatorChar + "map" + File.separatorChar + nume)); Map currentMap=(vnsim.map.object.Map)ois.readObject(); Globals.map = currentMap; Point tmpPoint, minPoint, maxPoint; Road tmpRoad; int i, j; i = 0; //currentMap = Globals.map; minPoint = new Point((double) 180, (double) 90); maxPoint = new Point((double) -180, (double) -90); while (i < currentMap.roads.size()) { tmpRoad = (Road) currentMap.roads.get(i); j = 0; while (j < tmpRoad.points.size()) {// for evey points from the selected road tmpPoint = (Point) tmpRoad.points.get(j); if (tmpPoint.getLatitude() < minPoint.getLatitude()) { minPoint.setLatitude(tmpPoint.getLatitude()); } if (tmpPoint.getLongitude() < minPoint.getLongitude()) { minPoint.setLongitude(tmpPoint.getLongitude()); } if (tmpPoint.getLatitude() > maxPoint.getLatitude()) { maxPoint.setLatitude(tmpPoint.getLatitude()); } if (tmpPoint.getLongitude() > maxPoint.getLongitude()) { maxPoint.setLongitude(tmpPoint.getLongitude()); } j++; } i++; } //System.out.println("Pct maxim ( "+maxPoint.getLatitude()+" "+maxPoint.getLongitude()+" )"); //System.out.println("Pct min ( "+minPoint.getLatitude()+" "+minPoint.getLongitude()+" )"); GlobalNetwork.pointMax = maxPoint; GlobalNetwork.pointMin = minPoint; ois.close(); } catch (Exception ex) { ex.printStackTrace(); //throw ex; } } public static boolean intersecRoad(CellInformation ci){ Map currentMap = Globals.map; Point tmpPoint; Road tmpRoad; int i, j; boolean gasit = false; i = 0; while (i < currentMap.roads.size()) { tmpRoad = (Road) currentMap.roads.get(i); j = 0; while (j < tmpRoad.points.size()){ tmpPoint = (Point) tmpRoad.points.get(j); if((ci.pointMin.getLatitude() ni, int pred[][], int predNum[], int nrHosts) { for (int k=0;k-1;dist--) for (int k=0; k ni,int nrHosts){ double distance[]= new double[nrHosts]; int assigned[]= new int[nrHosts]; int predNum[]= new int[nrHosts]; double betw[]= new double[nrHosts]; double current_betw[]=new double[nrHosts]; for (int i=0; i ni, ArrayList groups,int nrHosts,boolean assigned[]) { for (int k=0;k ni,ArrayList> groups, int nrHosts) { int numberOfGroups=0; boolean assigned[] = new boolean[nrHosts]; for (int i=0; i aux = new ArrayList(); aux.add(new Integer(i+1)); assigned[i]=true; assignToAGroup(i,numberOfGroups,ni, aux, nrHosts, assigned); groups.add(aux); } } return numberOfGroups; } public static boolean inGroup(int i,ArrayList group){ boolean result=false; for (int k=0;k> groups,int nrGroups){ boolean result=false; for (int k=0;k ni, double betw[],int nrHosts) { int best=0; double bestBetw=0; double betw2[] = new double[nrHosts]; for (int i=0;ibestBetw) { bestBetw=betw[i]; best=i; } } double minBetw=bestBetw; int linkToDelete=0; for (int i=0;i ni, double betw[], int nrHosts, double modThreshold) { int numberOfGroups_after=0; double numberOfLinks_before=0; ArrayList> groups_before= new ArrayList>(); ArrayList> groups_after= new ArrayList>(); double totalResults[][]= new double[nrHosts][nrHosts]; int adjacency_before[][]= new int[nrHosts][nrHosts]; for (int i=0;imodThreshold) { return q; } else { for (int i=0;i