Changeset 13806 for branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.cs
 Timestamp:
 04/27/16 17:17:00 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.cs
r13789 r13806 269 269 } 270 270 271 private static VariableInteractionNetwork ApplyThreshold(VariableInteractionNetwork originalNetwork, double threshold) { 272 var arcs = originalNetwork.Arcs.Where(x => x.Weight >= threshold).ToList(); 273 if (!arcs.Any()) return originalNetwork; 274 var filteredNetwork = new VariableInteractionNetwork(); 275 var cloner = new Cloner(); 276 var vertices = arcs.SelectMany(x => new[] { x.Source, x.Target }).Select(cloner.Clone).Distinct(); // arcs are not cloned 277 filteredNetwork.AddVertices(vertices); 278 filteredNetwork.AddArcs(arcs.Select(x => (IArc)x.Clone(cloner))); 279 280 var unusedJunctions = filteredNetwork.Vertices.Where(x => x.InDegree == 0 && x is JunctionNetworkNode).ToList(); 281 filteredNetwork.RemoveVertices(unusedJunctions); 282 var orphanedNodes = filteredNetwork.Vertices.Where(x => x.Degree == 0).ToList(); 283 filteredNetwork.RemoveVertices(orphanedNodes); 284 return filteredNetwork.Vertices.Any() ? filteredNetwork : originalNetwork; 285 } 286 271 287 private static double CalculateAverageQuality(RunCollection runs) { 272 288 var pd = (IRegressionProblemData)runs.First().Parameters["ProblemData"]; … … 374 390 var tb = (TextBox)sender; 375 391 errorProvider.SetError(tb, string.Empty); 376 var network = ApplyThreshold(variableInteractionNetwork, double.Parse(tb.Text)); 392 double impact; 393 if (!double.TryParse(tb.Text, out impact)) 394 impact = 0.1; 395 var network = ApplyThreshold(variableInteractionNetwork, impact); 377 396 graphChart.Graph = network; 378 }379 380 private static VariableInteractionNetwork ApplyThreshold(VariableInteractionNetwork originalNetwork, double threshold) {381 var arcs = originalNetwork.Arcs.Where(x => x.Weight >= threshold).ToList();382 if (!arcs.Any()) return originalNetwork;383 var filteredNetwork = new VariableInteractionNetwork();384 var cloner = new Cloner();385 var vertices = arcs.SelectMany(x => new[] { x.Source, x.Target }).Select(cloner.Clone).Distinct(); // arcs are not cloned386 filteredNetwork.AddVertices(vertices);387 filteredNetwork.AddArcs(arcs.Select(x => (IArc)x.Clone(cloner)));388 389 var unusedJunctions = filteredNetwork.Vertices.Where(x => x.InDegree == 0 && x is JunctionNetworkNode).ToList();390 filteredNetwork.RemoveVertices(unusedJunctions);391 var orphanedNodes = filteredNetwork.Vertices.Where(x => x.Degree == 0).ToList();392 filteredNetwork.RemoveVertices(orphanedNodes);393 return filteredNetwork;394 397 } 395 398
Note: See TracChangeset
for help on using the changeset viewer.