/// <summary> /// Populates the graph report /// </summary> /// <param name="graph">The graph.</param> public void Deploy(freeGraph graph) { name = graph.name; description = "Analysis of graph [" + graph.name + "] structure and other key metrics: " + graph.description; List <Double> ws = new List <double>(); //instanceCountCollection<freeGraphNodeBase> linkPerNodeFrequency = new instanceCountCollection<freeGraphNodeBase>(); aceDictionarySet <Int32, freeGraphNodeBase> nodesByNumberOfLinks = new aceDictionarySet <int, freeGraphNodeBase>(); foreach (var node in graph.nodes) { ws.Add(node.weight); Int32 lc = graph.CountLinks(node.name, true, true); nodesByNumberOfLinks.Add(lc, node); } if (!ws.Any()) { EmptyGraph = true; return; } TotalWeight = ws.Sum(); AvgWeight = ws.Average(); StdWeight = ws.GetStdDeviation(false); NodeCount = graph.nodes.Count; LinkRatio = graph.links.GetRatio(graph.nodes); List <String> processed = new List <String>(); List <Int32> linkFrequencies = nodesByNumberOfLinks.Keys.OrderByDescending(x => x).ToList(); Int32 maxLinkFreq = linkFrequencies.Max(); foreach (Int32 freq in linkFrequencies) { List <freeGraphNodeBase> nextSet = nodesByNumberOfLinks[freq].ToList(); foreach (freeGraphNodeBase n in nextSet) { if (!processed.Contains(n.name)) { var result = graph.GetLinkedNodes(new String[] { n.name }, 100, true, true, false); freeGraphIsland island = new freeGraphIsland(); island.Add(result); if (island.type != freeGraphIslandType.none) { islands.Add(island); processed.AddRange(island.nodes); } //result.ForEach(x => processed.Add(x.name)); } } } List <freeGraphIsland> _binodal = new List <freeGraphIsland>(); List <freeGraphIsland> _trinodal = new List <freeGraphIsland>(); List <freeGraphIsland> _polinodal = new List <freeGraphIsland>(); freeGraphIsland continent = null; if (islands.Any()) { Int32 max = 0; continent = islands.First(); foreach (var island in islands) { Int32 nc = island.nodes.Count; if (nc == 2) { Binodal += nc; BinodalN++; } if (nc == 3) { Trinodal += nc; TrinodalN++; } if (nc > 3) { Polinodal += nc; PolinodalN++; } if (max < nc) { max = nc; continent = island; } } } AllIslands = islands.Count; PolinodalRatio = Polinodal.GetRatio(graph.nodes.Count); if (continent != null) { var contNodes = graph.nodes.Where(x => continent.nodes.Contains(x.name)).ToList(); //var contNodes = ; ContinentMass = continent.nodes.Count; Double cw = contNodes.Sum(x => x.weight); ContinentWeightRate = cw.GetRatio(TotalWeight); ContinentMassRate = continent.nodes.Count.GetRatio(graph.nodes.Count); ContinentSize = graph.PingGraphSize(nodesByNumberOfLinks[maxLinkFreq], true, freeGraphPingType.maximumPingLength); } MainIsland = continent; }