diff --git a/Test2/Graph/Graph.sln b/Test2/Graph/Graph.sln new file mode 100644 index 0000000..e319b83 --- /dev/null +++ b/Test2/Graph/Graph.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Graph", "Graph\Graph.vcxproj", "{F230C9CD-70BB-467E-AA33-F672BC66E92C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Debug|x64.ActiveCfg = Debug|x64 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Debug|x64.Build.0 = Debug|x64 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Debug|x86.ActiveCfg = Debug|Win32 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Debug|x86.Build.0 = Debug|Win32 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Release|x64.ActiveCfg = Release|x64 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Release|x64.Build.0 = Release|x64 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Release|x86.ActiveCfg = Release|Win32 + {F230C9CD-70BB-467E-AA33-F672BC66E92C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {48E101DB-C036-4ACB-9F86-4400C2D227E3} + EndGlobalSection +EndGlobal diff --git a/Test2/Graph/Graph/Graph.c b/Test2/Graph/Graph/Graph.c new file mode 100644 index 0000000..2e09679 --- /dev/null +++ b/Test2/Graph/Graph/Graph.c @@ -0,0 +1,124 @@ +#include "Graph.h" +#include +#include +#include +#include "../../List/List/List.h" + +typedef struct Node +{ + int index; + int lenght; +} Node; + +typedef struct Graph +{ + Node** nodes; + int nodesCount; + int** matrix; +} Graph; + +Graph* createGraph(int numberOfNode) +{ + Graph* newGraph = calloc(1, sizeof(Graph)); + newGraph->nodes = calloc(numberOfNode, sizeof(Node*)); + for (int i = 0; i < numberOfNode; i++) + { + newGraph->nodes[i] = calloc(1, sizeof(int*)); + newGraph->nodes[i]->index = i; + newGraph->nodes[i]->lenght = 0; + } + newGraph->matrix = calloc(numberOfNode, sizeof(int*)); + for (int i = 0; i < numberOfNode; i++) + { + newGraph->matrix[i] = calloc(numberOfNode, sizeof(int)); + } + return newGraph; +} + +void edgeLength(Graph* graph, int firstVertex, int secondVertex, int lenght) +{ + graph->matrix[firstVertex][secondVertex] = lenght; + graph->matrix[secondVertex][firstVertex] = lenght; +} + +void printMatrix(Graph* graph) +{ + for (int i = 0; i < 6; i++) + { + printf("\n "); + for (int j = 0; j < 6; j++) + { + printf("%d ", graph->matrix[i][j]); + } + } +} + +int getLength(Graph* graph, int firstVertex, int secondVertex) +{ + return graph->matrix[firstVertex][secondVertex]; +} + + +typedef struct Table +{ + int numberOfSegments; + struct List** array; +} Table; + +Table* lenght(List* list, Error* error, Graph* graph) +{ + while (!isEmpty(list)) + { + Position* position = first(list, error); + while (position != NULL) + { + for (int i = 0; i < returnSize(list); i++) + { + int l = get(list, position, error); + int a = getLength(graph, i, l); + add(list, value, error); + if (a != 0) + { + add(newList, i ,error); + removeElement(list); + } + if (a == 0) + { + return; + } + lenght(list, error, graph); + next(position); + } + } + } +} + +void printTable(Table* table) +{ + for (int i = 0; i < table->numberOfSegments; i++) + { + printf("\n"); + print(table->array[i]); + } +} + + +int main(void) +{ + Graph* graph = NULL; + Error error = NOT_ERROR; + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + edgeLength(graph, 0, 1, 2); + List* list = createList(); + for (int i = 0; i < 6; i++) + { + add(list, i , &error); + } + +} \ No newline at end of file diff --git a/Test2/Graph/Graph/Graph.h b/Test2/Graph/Graph/Graph.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/Test2/Graph/Graph/Graph.h @@ -0,0 +1 @@ +#pragma once diff --git a/Test2/Graph/Graph/Graph.vcxproj b/Test2/Graph/Graph/Graph.vcxproj new file mode 100644 index 0000000..ed608b6 --- /dev/null +++ b/Test2/Graph/Graph/Graph.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {f230c9cd-70bb-467e-aa33-f672bc66e92c} + Graph + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/Test2/Graph/Graph/Graph.vcxproj.filters b/Test2/Graph/Graph/Graph.vcxproj.filters new file mode 100644 index 0000000..405c4e8 --- /dev/null +++ b/Test2/Graph/Graph/Graph.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + + + Файлы заголовков + + + \ No newline at end of file