コード例 #1
0
ファイル: graph_serv.cpp プロジェクト: hfhimage/jubatus
//@random
edge_info graph_serv::get_edge(const std::string& nid, const edge_id_t& id)const
{
  jubatus::graph::edge_info info;
  g_.get_model()->get_edge((jubatus::graph::edge_id_t)id, info);
  jubatus::edge_info ret;
  ret.p = info.p;
  ret.src = i2n(info.src);
  ret.tgt = i2n(info.tgt);
  return ret;
}
コード例 #2
0
ファイル: xigrid.c プロジェクト: bareid/xi
//put periodicopt == 1 for periodic boundary conditions (i.e., in a box)
void getnbrs(int cellnum, int NFAC, int Ncell, int *nbrs, int *nnbrs, int *closenbrs, int periodicopt) {
  int iposcen[3];
  int ipos[3];
  //tmp!!
  int iposchk[3];
  n2i(cellnum,Ncell,iposcen);
  int ix, iy, iz;
  int nbrindx = 0;
  int closecnt = 0;
  for(ix=iposcen[0]-NFAC;ix<=iposcen[0]+NFAC;ix++) {
    for(iy=iposcen[1]-NFAC;iy<=iposcen[1]+NFAC;iy++) {
      for(iz=iposcen[2]-NFAC;iz<=iposcen[2]+NFAC;iz++) {
        if(closenbrs[closecnt] == 0) {
          closecnt += 1;
          continue;
          }
        else {
          closecnt += 1;
          }
        if(periodicopt == 0) {
          if(ix < 0 || ix >= Ncell || iy < 0 || iy >= Ncell || iz < 0 || iz >= Ncell) {
            continue;
            }
          ipos[0] = ix;
          ipos[1] = iy;
          ipos[2] = iz;
          }
        else { //periodicopt = 1
          ipos[0] = wrapgridperiodic(ix,Ncell);
          ipos[1] = wrapgridperiodic(iy,Ncell);
          ipos[2] = wrapgridperiodic(iz,Ncell);
          }
        nbrs[nbrindx] = i2n(ipos,Ncell);
        #ifdef SANITYCHECKS
        n2i(nbrs[nbrindx],Ncell,iposchk);
        if(iposchk[0] != ix && iposchk[0] != ix-Ncell && iposchk[0] != ix+Ncell) {
          printf("x err!\n");
          exit(1);
          }
        if(iposchk[1] != iy && iposchk[1] != iy-Ncell && iposchk[1] != iy+Ncell) {
          printf("y err!\n");
          exit(1);
          }
        if(iposchk[2] != iz && iposchk[2] != iz-Ncell && iposchk[2] != iz+Ncell) {
          printf("z err!\n");
          exit(1);
          }
        #endif
        nbrindx += 1;
        }
      }
    }
  (*nnbrs) = nbrindx;
  #if defined(SANITYCHECKS) && defined(ASSERT_ON)
  assert(closecnt == (2*NFAC+1)*(2*NFAC+1)*(2*NFAC+1));
  #endif
  }
コード例 #3
0
ファイル: graph_serv.cpp プロジェクト: hfhimage/jubatus
//@random
std::vector<node_id> graph_serv::shortest_path(const shortest_path_req& req) const
{ 
  std::vector<jubatus::graph::node_id_t> ret0;
  jubatus::graph::preset_query q;
  framework::convert(req.q, q);
  g_.get_model()->shortest_path(n2i(req.src), n2i(req.tgt), req.max_hop, ret0, q);
  std::vector<node_id> ret;
  for(size_t i=0;i<ret0.size();++i){
    ret.push_back(i2n(ret0[i]));
  }
  return ret;
}