//This Generates Graphs when clicked private void button2_Click(object sender, EventArgs e) { int numGraphs = ((int)trackBar2.Value - (int)trackBar1.Value) / (int)numericUpDown1.Value; //sanity check on gui if (numGraphs > 20 && MessageBox.Show("Are you sure you want to generate " + numGraphs + " different graphs?", "Generate Graphs", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } for (int i = trackBar1.Value; i <= trackBar2.Value; i += (int)numericUpDown1.Value) { LightWeightGraph lwg = null; if (embeddingComboBox.SelectedIndex == 0) { lwg = LightWeightGraph.GetGeometricGraph(distMatrix, distances[i]); } else if (embeddingComboBox.SelectedIndex == 1) { lwg = LightWeightGraph.GetKNNGraph(distMatrix, i); } else { lwg = LightWeightGraph.GetStackedMST(distMatrix, (int)trackBar1.Value); } //Save GML String folder = pointSetFile.Substring(0, pointSetFile.LastIndexOf('\\')); lwg.SaveGML(folder + "\\" + graphPrefix + i + ".gml"); openFileDialog2.InitialDirectory = folder; //Save Graph format lwg.SaveGraph(folder + "\\" + graphPrefix + i + ".graph"); } MessageBox.Show("Graphs have been Generated!"); }
static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine( "Usage: Program.cs <Healthyfile> <Infectedfile> <Outputfile> <Group> "); Environment.Exit(0); } // AUTOMATING IBD // We need both a healthy network and an IBD network // COMMAND LINE: clusteringanalysis.exe healthyNet infectedNet VATorINTorTEN //convert from gml to graph String healthyfile = BackSlashRemover(args[0]); String infectedfile = BackSlashRemover(args[1]); String healthyFileName = ""; String infectedFileName = ""; String workingDir = Directory.GetCurrentDirectory(); String datapath = workingDir + "/Data"; datapath = BackSlashRemover(datapath); if (!Directory.Exists(datapath)) { Directory.CreateDirectory(datapath); } String outPath = BackSlashRemover(args[2]); if (outPath.Split('/').Length == 1) { outPath = $"{workingDir}/{outPath}"; } if (healthyfile.Contains("/")) { healthyFileName = healthyfile.Split('/').Last().Split('.').First(); } if (infectedfile.Contains("/")) { infectedFileName = infectedfile.Split('/').Last().Split('.').First(); } LightWeightGraph healthy = LightWeightGraph.GetGraphFromGML(healthyfile); LightWeightGraph infected = LightWeightGraph.GetGraphFromGML(infectedfile); healthy.SaveGraph($"{datapath}/{healthyFileName}.graph"); infected.SaveGraph($"{datapath}/{infectedFileName}.graph"); // Makes a list of what the nodes reference using (StreamWriter sw = new StreamWriter($"{datapath}/{healthyFileName}.txt", true)) { for (int i = 0; i < healthy.Nodes.Length; i++) { sw.WriteLine(healthy.Nodes[i].sharedName); } } using (StreamWriter sw = new StreamWriter($"{datapath}/{infectedFileName}.txt", true)) { for (int i = 0; i < infected.Nodes.Length; i++) { sw.WriteLine(infected.Nodes[i].sharedName); } } //we don't actually know the number of clusters in each graph - we want to cluster for 1 more than we start with //so cluster for 1 just to get the file. //HVATClust clust1 = new HVATClust(lwg2, K, useweights, 1, 0, reassign, hillclimb); HVATClust healthyClust1 = new HVATClust(healthy, 1, false, 1, 0, false, false); Partition t1 = healthyClust1.GetPartition(); int healthyClusters = t1.Clusters.Count; HVATClust infectedClust1 = new HVATClust(infected, 1, false, 1, 0, false, false); Partition t2 = infectedClust1.GetPartition(); int infectedClusters = t2.Clusters.Count; // Now we know the intital number of clusters, do the actual clustering //HVATClust clust1 = new HVATClust(lwg2, K, useweights, 1, 0, reassign, hillclimb); // This sees if the input cluster type can be parsed as the Enum, and if so // Uses a switch statement to decide which clustering to run. if (args.Length == 4) { List <DataOutStruct> outData = ConstructList(args[3], healthy, infected, healthyFileName, infectedFileName, healthyClusters, infectedClusters); outData = CombineOuts(infected, healthy, outData); using (StreamWriter sw = new StreamWriter(outPath)) { for (int i = 0; i < outData.Count(); i++) { sw.WriteLine($"{outData[i].Bacteria} {outData[i].GroupNum}"); } } Console.WriteLine("Done."); Console.WriteLine($"Output in: {outPath}"); } else { Console.WriteLine( "Please enter 3 parameters, in this order:\n " + "Healthy data path(.gml)\n " + "Unhealthy data path(.gml)\n " + "Desired Output Group(listed in Readme)\n"); } }