public double GetIndex(RelationIndexType type)
 {
     if (type == RelationIndexType.確信度)
     {
         return this.確信度;
     }
     if (type == RelationIndexType.補正確信度)
     {
         return this.補正確信度;
     }
     return 0;
 }
        public void ViewRelation(Comunity comunity, int max, RelationIndexType type, out List<ItemRelationViewData> list)
        {
            if (comunityDic == null)
            {
                CreateComunityDic();
            }
            foreach (var item in comunityDic.Values)
            {
                item.NewBrush(Colors.Transparent, 1);
            }
            comunity.NewBrush(Colors.Red, 0.8);

            int half = max / 2;
            int count = 0;
            foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)).Take(max))
            {
                if (comunityDic.ContainsKey(item.ItemId))
                {
                    if (count > half)
                    {
                        comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.2);
                    }
                    else
                    {
                        comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.6);
                    }
                    count++;
                }
            }
            list = new List<ItemRelationViewData>();
            int i = 1;
            foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)))
            {
                if (comunityDic.ContainsKey(item.ItemId))
                {
                    var c = comunityDic[item.ItemId];
                    list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 共起数 = item.共起数 ,確信度 = item.確信度.ToString("F3"), 補正確信度 = item.補正確信度.ToString("F3") });
                    i++;
                }
            }
        }
        public void ViewRelation(int max, RelationIndexType type, out List<ItemRelationViewData> list)
        {
            if (comunityDic == null)
            {
                CreateComunityDic();
            }
            foreach (var item in comunityDic.Values.Where(n => n.Selected == false))
            {
                item.NewBrush(Colors.Transparent, 1);
            }

            var selectedList = AllComunity.Where(n => n.Selected == true);
            List<ItemRelation> relationList = new List<ItemRelation>();
            foreach (var item in selectedList)
            {
                relationList.AddRange(item.Relations.Where(n => selectedList.Where(m => m.Id == n.ItemId).Any() == false));
            }
            var d = relationList.GroupBy(n => n.ItemId).Select(n => new { n.Key, a = n.Aggregate(1.0, (m, l) => l.GetIndex(type) * m) });

            int half = max / 2;
            int count = 0;

            foreach (var item in d.OrderByDescending(n => n.a).Where(n => comunityDic.ContainsKey(n.Key) == true).Take(max))
            {
                if (count > half)
                {
                    comunityDic[item.Key].NewBrush(Colors.Orange, 0.2);
                }
                else
                {
                    comunityDic[item.Key].NewBrush(Colors.Orange, 0.6);
                }
                count++;
            }
            int i = 1;
            list = new List<ItemRelationViewData>();
            foreach (var item in d.OrderByDescending(n => n.a))
            {
                if (comunityDic.ContainsKey(item.Key))
                {
                    var c = comunityDic[item.Key];
                    if (type == RelationIndexType.確信度)
                    {
                        list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 確信度 = item.a.ToString("F3"), });
                    }
                    else
                    {
                        list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 補正確信度 = item.a.ToString("F3") });
                    }
                    i++;
                }
            }

            //foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)).Take(max))
            //{
            //    if (comunityDic.ContainsKey(item.ItemId))
            //    {
            //        if (count > half)
            //        {
            //            comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.2);
            //        }
            //        else
            //        {
            //            comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.6);
            //        }
            //        count++;
            //    }
            //}
        }
        public void ViewRelation(Comunity comunity, int max, RelationIndexType type)
        {
            if (comunityDic == null)
            {
                CreateComunityDic();
            }
            foreach (var item in comunityDic.Values)
            {
                item.NewBrush(Colors.White, 1);
            }
            comunity.NewBrush(Colors.Red, 0.8);

            foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)).Take(max))
            {
                if (comunityDic.ContainsKey(item.ItemId))
                {
                    comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.5);
                }
            }
        }