/// <summary> /// Section Two. /// </summary> /// <returns>The five.</returns> /// <param name="result">Result.</param> private string SectionTwo(NodeDegreeReportFactory result) { Condition.Requires(result, "Result") .IsNotNull(); string table = ""; string title = "Node Id"; foreach (Graph graph in GraphTimeToGraphObjectDict.Values) { title += "\t" + graph.GraphEndTime; } table += title; Dictionary <string, int[]> NodeIsNodeIdToItsDegree = result.GetNodeDegrees(); foreach (string id in NodeIsNodeIdToItsDegree.Keys) { table += "\n" + id; foreach (int count in NodeIsNodeIdToItsDegree[id]) { table += string.Format("\t" + count); } } return(table); }
/// <summary> /// Initializes a new instance of the <see cref="T:mabuse.NodeDegreeReportWritter"/> class. /// </summary> /// <param name="result">Result.</param> /// <param name="filePath">File path.</param> public NodeDegreeReportWritter(NodeDegreeReportFactory result, string filePath) { //input parameter condition check Condition.Requires(result, "the analyzed result") .IsNotNull(); Condition.Requires(filePath, "path of file to write to") .IsNotEmpty() .IsNotNull() .EndsWith(".txt"); GraphTimeToGraphObjectDict = result.GraphTimeToGraphObjectDict; string[] lines = { SectionTwo(result) }; System.IO.File.WriteAllLines(@filePath, lines); }
/// <summary> /// write Node degree report. /// </summary> /// <param name="parser">Parser.</param> /// <param name="pathToFile">Path to file.</param> private static void NodeDegreeReport_Write(Parser parser, string pathToFile) { Condition.Ensures(parser.GetGraphTimeToGraphDictionary(), "graph create by parser") .IsNotNull() .IsNotEmpty(); Condition.Requires(pathToFile, "path to write to the fileA") .IsNotNullOrEmpty() .EndsWith(".txt") .IsNotNullOrWhiteSpace(); NodeDegreeReportFactory nodeDegreeReportFactory = new NodeDegreeReportFactory(parser); Condition.Ensures(nodeDegreeReportFactory, "result of parserB") .IsNotNull(); NodeDegreeReportWritter nodeDegreeReport = new NodeDegreeReportWritter(nodeDegreeReportFactory, pathToFile); }