示例#1
0
        public AnonymizedLocation Anonymize(OriginalLocation msc)
        {
            SimulateOtherUsers(msc); //Only for the purpose of this prototype. Remove for video
            var n = AddMessage(msc);

            var gmMark = _gm.SubGraph(n);
            var m      = LocalKSearch(msc.K, msc, gmMark).ToList();

            if (!m.Any())
            {
                return(null);
            }

            _im.Remove(msc);
            _hm.Remove(msc);
            _gm.RemoveNode(msc);
            var bbox = Mbr(m);

            //TODO: Remove for video
            _im = new MultidimensionalIndex();
            _hm = new ExpirationHeap();
            _gm = new ConstraintGraph();

            return(new AnonymizedLocation
            {
                Id = msc.Id,
                LatMin = bbox.MinX,
                LatMax = bbox.MaxX,
                LonMin = bbox.MinY,
                LonMax = bbox.MaxY
            });
        }
示例#2
0
        public ConstraintGraph SubGraph(IEnumerable <OriginalLocation> n)
        {
            var result = new ConstraintGraph();

            foreach (var node in _nodes.Where(node => n.Contains(node.Message)))
            {
                result.AddNode(node.Message);

                foreach (var edge in node.Edges.Where(edge => n.Contains(edge.To)))
                {
                    result.AddEdge(edge.From, edge.To);
                }
            }

            return(result);
        }
示例#3
0
        private static IEnumerable <OriginalLocation> LocalKSearch(int k, OriginalLocation msc, ConstraintGraph gmMark)
        {
            var u = gmMark.Nbr(msc).Where(ms => ms.K <= k).ToList();

            if (u.Count() < k - 1)
            {
                return(new List <OriginalLocation>());
            }

            var l = 0;

            while (l != u.Count())
            {
                l = u.Count();
                foreach (var ms in new List <OriginalLocation>(u))
                {
                    if (gmMark.Nbr(ms).Count() < k - 2)
                    {
                        u.Remove(ms);
                        gmMark.RemoveNode(ms);
                    }
                }
            }

            return(gmMark.FindClique(msc, k));
        }