public void GenerateBAModelWithAging(int n, int m0, int m, double v) { RunWithProgressBar(() => { var network = _networkGenerator.GenerateBarabasiAlbertModelWithAging(n, m0, m, v); var wrapper = new NetworkWrapper($"BA_{BACounter++}", network, network.GetIncidenceMatrix()); Networks.Add(wrapper); OnNetworkAdd?.Invoke(wrapper); }); }
public void LoadNetwork(string path, int rowsToSkip) { RunWithProgressBar(() => { var(network, incidenceMatrix) = _networkFileLoader.LoadNetwork(path, rowsToSkip); string fileName = Path.GetFileNameWithoutExtension(path); var wrapper = new NetworkWrapper(fileName, network, incidenceMatrix); Networks.Add(wrapper); OnNetworkAdd?.Invoke(wrapper); }); }
public void CreateNetworkFromCommunity(string networkName, string communityName) { var network = GetNetwork(networkName); var community = network.Communities.Single(e => e.Id.ToString() == communityName); // cloning because new nodes must be used var newNetwork = new Network(community.Nodes).Clone(); var newNetworkWrapper = new NetworkWrapper($"{networkName} - {communityName}", newNetwork, newNetwork.GetIncidenceMatrix()); Networks.Add(newNetworkWrapper); OnNetworkAdd?.Invoke(newNetworkWrapper); }
private void GetNetworkPlot(NetworkWrapper network) { string tempFileName = TempFileHelper.CreateTmpFile(); string script = RScriptCreator.CreatePlotNetworkScript(tempFileName, network.Network, network.Communities); REngineRunner.RunFromCmd(script); Bitmap bitmap; using (var fs = File.Open(tempFileName, FileMode.Open)) { bitmap = new Bitmap(fs); } TempFileHelper.DeleteTmpFile(tempFileName); network.Plot = bitmap; OnNetworkPlotUpdate?.Invoke(network); }
private void InitNetwork(NetworkWrapper network) { //RunWithProgressBar(() => //{ // network.Network.ComputeClusteringCoefficient(); // network.Stats.ClusteringCoefficient = network.Network.GetGlobalClusteringCoefficient(); // OnNetworkStatsUpdate?.Invoke(network); //}); RunWithProgressBar(() => { network.DistanceMatrix = network.IncidenceMatrix.GetDistanceMatrix(); network.Stats.MeanDistance = network.DistanceMatrix.GetMeanDistance(); network.Stats.ClosenessCentrality = network.DistanceMatrix.GetClosenessCentralityVector().Average; network.Stats.Diameter = network.DistanceMatrix.GetDiameter(); network.Network.ComputeClusteringCoefficient(); network.Stats.ClusteringCoefficient = network.Network.GetGlobalClusteringCoefficient(); OnNetworkStatsUpdate?.Invoke(network); }); RunWithProgressBar(() => { network.Stats.DegreeCentrality = network.Network.GetAverageDegree(); network.Stats.Edges = network.Network.Edges; network.Stats.Nodes = network.Network.Nodes.Count; network.Stats.Components = network.Network.CountComponents(); OnNetworkStatsUpdate?.Invoke(network); }); RunWithProgressBar(() => { GetNetworkPlot(network); }); }