Ejemplo n.º 1
0
  private void deleteObject(int vID) {
    // TODO Auto-generated method stub
    Vertex v = GraphPool.getSignleton().getVertex(vID);

    v.deleteOneAssocMsgObj();

    int maxLevel = RNetHierarchy.getSignleton().getMaxLevel();
    for (int i = 0; i <= maxLevel; i++) {
      int rID = v.getInsideRNetID(i);
      RNet rnet = RNetHierarchy.getSignleton().getRNet(rID);
      // rnet.setContainObj(true);
      rnet.decreaseObjCnt(1);
    }
  }
Ejemplo n.º 2
0
  private void insertObject(int vID) {
    // TODO Auto-generated method stub
    Vertex v = GraphPool.getSignleton().getVertex(vID);

    int msgSize = MsgObjPool.getSignleton().getMsgSize();

    MsgObj obj = new MsgObj(msgSize, v.getloc().getCoord(0), v.getloc().getCoord(1));
    obj.setAssocVertex(vID);
    MsgObjPool.getSignleton().insertMsg(obj);
    v.insertAssocMsgObj(msgSize);

    int maxLevel = RNetHierarchy.getSignleton().getMaxLevel();
    for (int i = 0; i <= maxLevel; i++) {
      int rID = v.getInsideRNetID(i);
      RNet rnet = RNetHierarchy.getSignleton().getRNet(rID);
      // rnet.setContainObj(true);
      rnet.increaseObjCnt(1);
    }
  }
Ejemplo n.º 3
0
  public ArrayList<MsgObjPath> getRoadKNN(int srcVID) {
    Vertex srcV = GraphPool.getSignleton().getVertex(srcVID);
    RNet leafR = RNetHierarchy.getSignleton().getRNet(srcV.getLeafRnetID());
    TreeSet<Path> queue = new TreeSet<Path>();
    TreeSet<MsgObjPath> settleSet = new TreeSet<MsgObjPath>();
    TreeSet<MsgObjPath> unSettleSet = new TreeSet<MsgObjPath>();

    boolean finish = false;

    if (leafR.hasMsgObjInside()) {
      Dijkstra dijkstra = new Dijkstra(leafR.getGraph());
      dijkstra.execute(srcVID);
      TreeSet<MsgObjPath> msgset = dijkstra.getPath2Objects(leafR);

      finish = doSettle(settleSet, unSettleSet, msgset);

      if (!finish) {
        TreeSet<MsgObjPath> borset = dijkstra.getPath2Borders(leafR);
        finish = doSettle(settleSet, unSettleSet, borset);
      }
    } else {
      Dijkstra dijkstra = new Dijkstra(leafR.getGraph());
      dijkstra.execute(srcVID);
      TreeSet<MsgObjPath> borset = dijkstra.getPath2Borders(leafR);
      finish = doSettle(settleSet, unSettleSet, borset);
    }

    TreeSet<ChoosePathUnit> pqueue = new TreeSet<ChoosePathUnit>();
    while (!finish) {
      MsgObjPath first = unSettleSet.pollFirst();
      int visitedLevel = first.currentVisitedRNetLevel;
      int vID = first.getTailVID();
      Vertex v = GraphPool.getSignleton().getVertex(vID);
      if (v.getHighestBorderLevel() < 0) {
        System.out.println("v must be a border");
        System.exit(0);
      }

      RNet highR =
          RNetHierarchy.getSignleton().getRNet(v.getInsideRNetID(v.getHighestBorderLevel()));

      if (!highR.isLeafRNet()) {
        ChoosePathUnit unit = new ChoosePathUnit();
        unit.rnet = highR.getRNetID();
        unit.path = first.clone();
        pqueue.add(unit);
      } else {
        /*leaf, search silbing*/
        List<Integer> nlist = v.getNeighbors();
        for (int i = 0; i < nlist.size(); i++) {
          Vertex anoV = GraphPool.getSignleton().getVertex(nlist.get(i));
        }
      }
    }

    return null;
  }
Ejemplo n.º 4
0
 private void ChoosePath(
     TreeSet<VisitedObject> queue,
     Vertex popVertex,
     double dist,
     HashSet<Integer> visitedN,
     HashSet<Integer> visitedO) {
   // TODO Auto-generated method stub
   int leafRID = popVertex.getLeafRnetID();
   RNet leafRnet = RNetHierarchy.getSignleton().getRNet(leafRID);
   int leafLevel = leafRnet.getLevel();
   if (popVertex.isBorderNode(leafLevel)) {
     int highestLevel = popVertex.getHighestBorderLevel();
     for (int i = highestLevel; i <= leafLevel; i++) {
       int tmpRID = popVertex.getInsideRNetID(i);
       RNet tmpRNet = RNetHierarchy.getSignleton().getRNet(tmpRID);
       if (tmpRNet.hasMsgObjInside()) {
         if (tmpRNet.isLeafRNet()) {
           List<Integer> neighbors = popVertex.getNeighbors();
           for (int j = 0; j < neighbors.size(); j++) {
             int id = neighbors.get(j).intValue();
             Edge e = GraphPool.getSignleton().getEdge(popVertex.getId(), id);
             double newDist = dist + e.getWeight();
             VisitedObject oneObj = new VisitedObject(id, -1, newDist);
             queue.add(oneObj);
           }
         }
         continue;
       } else {
         ShortCutSet scSet = tmpRNet.getShortCutSet(popVertex.getId());
         if (scSet == null) break;
         HashMap<Integer, Path> scMap = scSet.getSCMap();
         Iterator<Integer> scMIter = scMap.keySet().iterator();
         while (scMIter.hasNext()) {
           Integer destID = (Integer) scMIter.next();
           double newDist = dist + scMap.get(destID).cost;
           VisitedObject oneObj = new VisitedObject(destID.intValue(), -1, newDist);
           queue.add(oneObj);
         }
         List<Integer> neighbors = popVertex.getNeighbors();
         for (int j = 0; j < neighbors.size(); j++) {
           int id = neighbors.get(j).intValue();
           Vertex neiVertex = GraphPool.getSignleton().getVertex(id);
           if (neiVertex.getInsideRNetID(i) != popVertex.getInsideRNetID(i)) {
             Edge e = GraphPool.getSignleton().getEdge(popVertex.getId(), id);
             double newDist = dist + e.getWeight();
             VisitedObject oneObj = new VisitedObject(id, -1, newDist);
             queue.add(oneObj);
           }
         }
         break;
       }
     }
   } else {
     List<Integer> neighbors = popVertex.getNeighbors();
     for (int i = 0; i < neighbors.size(); i++) {
       int id = neighbors.get(i).intValue();
       Edge e = GraphPool.getSignleton().getEdge(popVertex.getId(), id);
       double newDist = dist + e.getWeight();
       VisitedObject oneObj = new VisitedObject(id, -1, newDist);
       queue.add(oneObj);
     }
   }
 }