public void CategorySort(ClusteringResult baseResult) { List<Category> list = new List<Category>(); List<Category> list2 = new List<Category>(this.Categories); foreach (var item in baseResult.Categories) { if (list2.Count > 0) { var idList = item.GetComuity().Select(n => n.Id); var c = list2.OrderByDescending(n => n.GetComuity().Select(m => m.Id).Intersect(idList).Count()).First(); list2.Remove(c); list.Add(c); } else { list.Add(new Category()); } } this.Categories.Clear(); foreach (var item in list) { this.Categories.Add(item); } var layerNames = this.LayerGroup.Select(n => n.Key).Distinct().ToArray(); LayerGroup.Clear(); foreach (var item in layerNames) { LayerGroup lg = new LayerGroup() { Name = item, Items = new System.Collections.ObjectModel.ObservableCollection<Layer>() }; LayerGroup.Add(item, lg); foreach (var item2 in Categories) { lg.Items.Add(item2.GetLayer(item)); } } }
public ClusteringResult Clone() { ClusteringResult target = new ClusteringResult(); target.Parent = this.Parent; HashSet<string> layerNames = new HashSet<string>(); List<Category> categoryList = new List<Category>(); target.checkDividCategoryDic = this.checkDividCategoryDic; target.random = new Random(random.Next()); foreach (var category in Categories) { var ca = new Category(); target.Categories.Add(ca); categoryList.Add(ca); foreach (var item in category.Layer) { var layer = ca.GetLayer(item.Key); layerNames.Add(item.Key); foreach (ComunityEx comuinity in item.Value.Comunities) { layer.Comunities.Add(comuinity); target.ComunityList.Add(comuinity); target.ComunityDic.Add(comuinity.Id, comuinity); } } } foreach (var item in layerNames) { LayerGroup lg = new LayerGroup() { Name = item, Items = new System.Collections.ObjectModel.ObservableCollection<Layer>() }; target.LayerGroup.Add(item, lg); foreach (var item2 in Categories) { lg.Items.Add(item2.GetLayer(item)); } } return target; }
public static void CreateLayerGroup(ClusterTable clusterTable) { clusterTable.LayerGroup = new List<LayerGroup>(); List<string> layerNameList = new List<string>(); foreach (var item in clusterTable.Categories) { foreach (var item2 in item.Layer) { layerNameList.Add(item2.Value.Name); } } layerNameList = layerNameList.Where(n => n != null).Distinct().OrderBy(n => n).ToList(); foreach (var item in layerNameList) { var lg = new LayerGroup() { Name = item, Items = new System.Collections.ObjectModel.ObservableCollection<Layer>() }; clusterTable.LayerGroup.Add(lg); foreach (var item2 in clusterTable.Categories) { if (item2.Layer.ContainsKey(item) == false) { item2.Layer.Add(item, new Layer()); } lg.Items.Add(item2.Layer[item]); } } }