Changeset 13893 for branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/Layout/ConstrainedForceDirectedLayout.cs
- Timestamp:
- 06/14/16 17:12:51 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/Layout/ConstrainedForceDirectedLayout.cs
r13821 r13893 25 25 using System.Linq; 26 26 using Cola; 27 using HeuristicLab.Common;28 27 using HeuristicLab.Core; 29 28 using HeuristicLab.Random; … … 180 179 181 180 private static IEnumerable<Cluster> IdentifyClusters(RectanglePtrs rectangles, ColaEdges edges) { 182 var vertices = rectangles.Select(x => new Vertex()).ToList(); 181 // build a graph using the rectangles and the edges 182 var vertices = new List<IVertex>(rectangles.Select(x => new Vertex())); 183 183 foreach (var e in edges) { 184 184 var i = (int)e.first; … … 188 188 vertices[j].AddArc(arc); 189 189 } 190 while (vertices.Min(x => x.Weight).IsAlmost(0)) { 191 foreach (var v in vertices) { 192 if (v.Weight > 0) continue; 193 v.Weight = vertices.Max(x => x.Weight) + 1; 190 // group vertices into clusters 191 var clusters = new List<RectangularCluster>(); 192 for (int i = 0; i < vertices.Count; ++i) { 193 var v = vertices[i]; 194 if (v.Weight > 0) { 195 clusters[(int)Math.Round(v.Weight) - 1].addChildNode((uint)i); 196 } else { 197 var cluster = new RectangularCluster(); 198 cluster.addChildNode((uint)i); 199 clusters.Add(cluster); 200 v.Weight = clusters.Count; 194 201 ColourNeighbours(v); 195 202 } 196 203 } 197 var colors = vertices.Select(x => (int)Math.Round(x.Weight)).ToList(); 198 foreach (var i in colors.Distinct()) { 199 var cluster = new RectangularCluster(); 200 for (int j = 0; j < colors.Count; ++j) { 201 if (colors[j] == i) cluster.addChildNode((uint)j); 202 } 203 yield return cluster; 204 } 204 return clusters; 205 205 } 206 206
Note: See TracChangeset
for help on using the changeset viewer.