/// <summary> /// calculate center list in detail for the given user /// </summary> /// <param name="uid"></param> /// <returns>returns list(center),包括center的id,空间范围,poi列表</returns> public List <Center> Center_list2(string uid, double d = 0.1, double theta = 0.05) { //check whether datasets have been loaded if (!ds.isInitialized()) { Initial(); } //sort user's check-in POI by check-in frequency var temp = from item in usercheckins[uid] orderby item.Value descending select item; var poi_list = new List <string>(); foreach (var item in temp) { poi_list.Add(item.Key); } //store POIs which have already been clustered Dictionary <string, string> POI_Center = new Dictionary <string, string>(); //retult list store all <centers,check-in probability> for the given uid var center_list = new List <Center>(); //temp center list for a center var curr_center = new List <string>(); int center_no = 0; //当前 center 的index int total_freq = 0; //指定 user 在该 center 的签到数目 for (int i = 0; i < poi_list.Count; i++) { if (!POI_Center.ContainsKey(poi_list[i])) { //reset regional variables center_no++; curr_center.Clear(); total_freq = 0; curr_center.Add(poi_list[i]); total_freq += usercheckins[uid][poi_list[i]]; //设定当前center的spatial range rectangle rec = new rectangle(POIcategory[poi_list[i]].Item1, POIcategory[poi_list[i]].Item2, POIcategory[poi_list[i]].Item1, POIcategory[poi_list[i]].Item2); for (int j = i + 1; j < poi_list.Count; j++) { if ((!POI_Center.ContainsKey(poi_list[j])) & ( DistanceOfTwoPoints(POIcategory[poi_list[i]].Item1, POIcategory[poi_list[i]].Item2, POIcategory[poi_list[j]].Item1, POIcategory[poi_list[j]].Item2, GaussSphere.WGS84) < d)) { curr_center.Add(poi_list[j]); total_freq += usercheckins[uid][poi_list[j]]; //更新rec范围 rec.update(POIcategory[poi_list[j]].Item1, POIcategory[poi_list[j]].Item2); } } if (total_freq >= (usercheckins[uid].Values.Sum() * theta))//满足center条件 { //center_list.Add(poi_list[i], (total_freq / (usercheckins[uid].Values.Sum() + 0.0))); var cent = new Center(poi_list[i], rec, curr_center); center_list.Add(cent); foreach (var item in curr_center) { POI_Center.Add(item, poi_list[i]); } } } } return(center_list); }
public List <string> poi_list; //中心选择时属于该center的POI //public Dictionary<string, List<string>> cate_poi;//用户在该中心访问过的 类型,POI集合 public Center(string id, rectangle sp, List <string> poi_list) { this.c_id = id; this.sp = sp; this.poi_list = poi_list; }