Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

{0, 0, 0, 9 },
{3, 6, 9, 0 }
};
Assert.AreEqual(AlgorithmPrima.Algorithm(graphSecond), graphSecondResult);

This comment was marked as resolved.

{
try
{
FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph("..\\..\\..\\Routers2.txt")), "RoutersTestResult.txt");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По условию, Пути до входного и выходного файлов должны приниматься в качестве параметров.

{
Console.Error.WriteLine("Граф несвязный!");
}
//Routers.WriteInFile(AlgorithmPrima.Algorithm(Routers.CreateGraph(args[0])), args[1]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А вот закомментированный код не нужен


namespace hw5Routers
{
public class GraphDisconnectedException : Exception

This comment was marked as resolved.

using System.Collections.Generic;
using System.Text;

namespace hw5Routers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пространство имён должно называться с заглавной

{
stringLine = stringLine.Replace(':', ' ');
stringLine = stringLine.Replace(',', ' ');
string[] lineDrop = stringLine.Split(" ", StringSplitOptions.RemoveEmptyEntries);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split может принимать сразу массив символов, по которым разбивать строку, что позволяет не делать Replace-ы


private static int CountsVertexs(string path)
{
var file = new StreamReader(path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var file = new StreamReader(path);
using var file = new StreamReader(path);

return matrix;
}

private static int CountsVertexs(string path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FileInfo fileOut = new FileInfo(filePath);
var fileOut = new FileInfo(filePath);

{
fileOut.Delete();
}
FileStream newFile = new FileStream(filePath, FileMode.Create);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FileStream newFile = new FileStream(filePath, FileMode.Create);
using var newFile = new FileStream(filePath, FileMode.Create);

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почти всё ок, но пока не совсем ок.

isConsist[indexFirst] = true;
for (int indexSecond = 0; indexSecond < size; indexSecond++)
{
if (matrix[indexFirst, indexSecond] != 0 && isConsist[indexSecond] == false && matrix[indexFirst, indexSecond] > key[indexSecond])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И даже этому классу надо комментарий :)

{
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше всё-таки это двумя отдельными операциями делать

fileOut.Delete();
}
using var newFile = new FileStream(filePath, FileMode.Create);
StreamWriter file = new StreamWriter(newFile);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var

{
try
{
FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph(args[0])), args[1]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это если предположить, что нам реально передали два параметра. А скорее всего, первый раз программу вообще без параметров запустят, потому что привыкли, что в этом случае она распечатает подсказку по использованию (так делают все нормальные консольные утилиты, кому нужны параметры для работы).


namespace Hw5Routers
{
public class NoParametersException : Exception
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы не поверите, ему тоже нужны комментарии

{
Console.Error.WriteLine("Граф несвязный!");
}
catch (NoParametersException)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оно не так работает. Проверяли, что будет, если без параметров запустить?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants