Conversation
| {0, 0, 0, 9 }, | ||
| {3, 6, 9, 0 } | ||
| }; | ||
| Assert.AreEqual(AlgorithmPrima.Algorithm(graphSecond), graphSecondResult); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
hw5Routers/hw5Routers/Program.cs
Outdated
| { | ||
| try | ||
| { | ||
| FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph("..\\..\\..\\Routers2.txt")), "RoutersTestResult.txt"); |
There was a problem hiding this comment.
По условию, Пути до входного и выходного файлов должны приниматься в качестве параметров.
hw5Routers/hw5Routers/Program.cs
Outdated
| { | ||
| Console.Error.WriteLine("Граф несвязный!"); | ||
| } | ||
| //Routers.WriteInFile(AlgorithmPrima.Algorithm(Routers.CreateGraph(args[0])), args[1]); |
There was a problem hiding this comment.
А вот закомментированный код не нужен
|
|
||
| namespace hw5Routers | ||
| { | ||
| public class GraphDisconnectedException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace hw5Routers |
There was a problem hiding this comment.
Пространство имён должно называться с заглавной
| { | ||
| stringLine = stringLine.Replace(':', ' '); | ||
| stringLine = stringLine.Replace(',', ' '); | ||
| string[] lineDrop = stringLine.Split(" ", StringSplitOptions.RemoveEmptyEntries); |
There was a problem hiding this comment.
Split может принимать сразу массив символов, по которым разбивать строку, что позволяет не делать Replace-ы
|
|
||
| private static int CountsVertexs(string path) | ||
| { | ||
| var file = new StreamReader(path); |
There was a problem hiding this comment.
| var file = new StreamReader(path); | |
| using var file = new StreamReader(path); |
| return matrix; | ||
| } | ||
|
|
||
| private static int CountsVertexs(string path) |
There was a problem hiding this comment.
| private static int CountsVertexs(string path) | |
| private static int CountVertexes(string path) |
| /// </summary> | ||
| public static void WriteInFile(int[,] matrix, string filePath) | ||
| { | ||
| FileInfo fileOut = new FileInfo(filePath); |
There was a problem hiding this comment.
| FileInfo fileOut = new FileInfo(filePath); | |
| var fileOut = new FileInfo(filePath); |
| { | ||
| fileOut.Delete(); | ||
| } | ||
| FileStream newFile = new FileStream(filePath, FileMode.Create); |
There was a problem hiding this comment.
| FileStream newFile = new FileStream(filePath, FileMode.Create); | |
| using var newFile = new FileStream(filePath, FileMode.Create); |
yurii-litvinov
left a comment
There was a problem hiding this comment.
Почти всё ок, но пока не совсем ок.
| isConsist[indexFirst] = true; | ||
| for (int indexSecond = 0; indexSecond < size; indexSecond++) | ||
| { | ||
| if (matrix[indexFirst, indexSecond] != 0 && isConsist[indexSecond] == false && matrix[indexFirst, indexSecond] > key[indexSecond]) |
There was a problem hiding this comment.
| if (matrix[indexFirst, indexSecond] != 0 && isConsist[indexSecond] == false && matrix[indexFirst, indexSecond] > key[indexSecond]) | |
| if (matrix[indexFirst, indexSecond] != 0 && !isConsist[indexSecond] && matrix[indexFirst, indexSecond] > key[indexSecond]) |
|
|
||
| namespace Hw5Routers | ||
| { | ||
| public static class FileFunctions |
There was a problem hiding this comment.
И даже этому классу надо комментарий :)
| { | ||
| var numberSecond = Int32.Parse(lineDrop[i]) - 1; | ||
| var distance = Int32.Parse(lineDrop[i + 1].Substring(1, lineDrop[i + 1].Length - 2)); | ||
| matrix[numberFirst, numberSecond] = matrix[numberSecond, numberFirst] = distance; |
There was a problem hiding this comment.
Лучше всё-таки это двумя отдельными операциями делать
| fileOut.Delete(); | ||
| } | ||
| using var newFile = new FileStream(filePath, FileMode.Create); | ||
| StreamWriter file = new StreamWriter(newFile); |
| { | ||
| try | ||
| { | ||
| FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph(args[0])), args[1]); |
There was a problem hiding this comment.
Это если предположить, что нам реально передали два параметра. А скорее всего, первый раз программу вообще без параметров запустят, потому что привыкли, что в этом случае она распечатает подсказку по использованию (так делают все нормальные консольные утилиты, кому нужны параметры для работы).
|
|
||
| namespace Hw5Routers | ||
| { | ||
| public class NoParametersException : Exception |
There was a problem hiding this comment.
Вы не поверите, ему тоже нужны комментарии
| { | ||
| Console.Error.WriteLine("Граф несвязный!"); | ||
| } | ||
| catch (NoParametersException) |
There was a problem hiding this comment.
Оно не так работает. Проверяли, что будет, если без параметров запустить?
No description provided.