diff --git a/Binaries/PackagingLog.html b/Binaries/PackagingLog.html new file mode 100644 index 0000000..2a01279 --- /dev/null +++ b/Binaries/PackagingLog.html @@ -0,0 +1,16 @@ +
+mcc -o Kruskal -W 'WinMain:Kruskal,version=1.0' -T link:exe -d C:\Users\esteb\Desktop\Kruskal\Kruskal\for_testing -v C:\Users\esteb\Desktop\Kruskal\KruskalAppEditor.mlapp -r 'C:\Program Files\MATLAB\R2020a\toolbox\compiler\resources\default_icon.ico' 
+Compiler version: 8.0 (R2020a)
+
+Dependency analysis by REQUIREMENTS.
+
+Parsing file "C:\Users\esteb\Desktop\Kruskal\KruskalAppEditor.mlapp"
+	(referenced from command line).
+Generating file "C:\Users\esteb\Desktop\Kruskal\Kruskal\for_testing\readme.txt".
+Packaging...
+Creating the bundle...
+Creating the install agent URL file...
+Web based installer created at C:\Users\esteb\Desktop\Kruskal\Kruskal\for_redistribution\MyAppInstaller_web.exe.
+Packaging complete.
+Elapsed packaging time was: 18 seconds.
+
diff --git a/Binaries/for_redistribution/MyAppInstaller_web.exe b/Binaries/for_redistribution/MyAppInstaller_web.exe new file mode 100644 index 0000000..1bf86c1 Binary files /dev/null and b/Binaries/for_redistribution/MyAppInstaller_web.exe differ diff --git a/Binaries/for_redistribution_files_only/Kruskal.exe b/Binaries/for_redistribution_files_only/Kruskal.exe new file mode 100644 index 0000000..32dc313 Binary files /dev/null and b/Binaries/for_redistribution_files_only/Kruskal.exe differ diff --git a/Binaries/for_redistribution_files_only/readme.txt b/Binaries/for_redistribution_files_only/readme.txt new file mode 100644 index 0000000..a9e5260 --- /dev/null +++ b/Binaries/for_redistribution_files_only/readme.txt @@ -0,0 +1,47 @@ +Kruskal Executable + +1. Prerequisites for Deployment + +Verify that version 9.8 (R2020a) of the MATLAB Runtime is installed. +If not, you can run the MATLAB Runtime installer. +To find its location, enter + + >>mcrinstaller + +at the MATLAB prompt. +NOTE: You will need administrator rights to run the MATLAB Runtime installer. + +Alternatively, download and install the Windows version of the MATLAB Runtime for R2020a +from the following link on the MathWorks website: + + https://www.mathworks.com/products/compiler/mcr/index.html + +For more information about the MATLAB Runtime and the MATLAB Runtime installer, see +"Distribute Applications" in the MATLAB Compiler documentation +in the MathWorks Documentation Center. + +2. Files to Deploy and Package + +Files to Package for Standalone +================================ +-Kruskal.exe +-MCRInstaller.exe + Note: if end users are unable to download the MATLAB Runtime using the + instructions in the previous section, include it when building your + component by clicking the "Runtime included in package" link in the + Deployment Tool. +-This readme file + + + +3. Definitions + +For information on deployment terminology, go to +https://www.mathworks.com/help and select MATLAB Compiler > +Getting Started > About Application Deployment > +Deployment Product Terms in the MathWorks Documentation +Center. + + + + diff --git a/Binaries/for_redistribution_files_only/splash.png b/Binaries/for_redistribution_files_only/splash.png new file mode 100644 index 0000000..d60c6fa Binary files /dev/null and b/Binaries/for_redistribution_files_only/splash.png differ diff --git a/Binaries/for_testing/Kruskal.exe b/Binaries/for_testing/Kruskal.exe new file mode 100644 index 0000000..32dc313 Binary files /dev/null and b/Binaries/for_testing/Kruskal.exe differ diff --git a/Binaries/for_testing/mccExcludedFiles.log b/Binaries/for_testing/mccExcludedFiles.log new file mode 100644 index 0000000..9d0f909 --- /dev/null +++ b/Binaries/for_testing/mccExcludedFiles.log @@ -0,0 +1,2 @@ +The List of Excluded Files +Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule diff --git a/Binaries/for_testing/readme.txt b/Binaries/for_testing/readme.txt new file mode 100644 index 0000000..a9e5260 --- /dev/null +++ b/Binaries/for_testing/readme.txt @@ -0,0 +1,47 @@ +Kruskal Executable + +1. Prerequisites for Deployment + +Verify that version 9.8 (R2020a) of the MATLAB Runtime is installed. +If not, you can run the MATLAB Runtime installer. +To find its location, enter + + >>mcrinstaller + +at the MATLAB prompt. +NOTE: You will need administrator rights to run the MATLAB Runtime installer. + +Alternatively, download and install the Windows version of the MATLAB Runtime for R2020a +from the following link on the MathWorks website: + + https://www.mathworks.com/products/compiler/mcr/index.html + +For more information about the MATLAB Runtime and the MATLAB Runtime installer, see +"Distribute Applications" in the MATLAB Compiler documentation +in the MathWorks Documentation Center. + +2. Files to Deploy and Package + +Files to Package for Standalone +================================ +-Kruskal.exe +-MCRInstaller.exe + Note: if end users are unable to download the MATLAB Runtime using the + instructions in the previous section, include it when building your + component by clicking the "Runtime included in package" link in the + Deployment Tool. +-This readme file + + + +3. Definitions + +For information on deployment terminology, go to +https://www.mathworks.com/help and select MATLAB Compiler > +Getting Started > About Application Deployment > +Deployment Product Terms in the MathWorks Documentation +Center. + + + + diff --git a/Binaries/for_testing/requiredMCRProducts.txt b/Binaries/for_testing/requiredMCRProducts.txt new file mode 100644 index 0000000..3ed6af0 --- /dev/null +++ b/Binaries/for_testing/requiredMCRProducts.txt @@ -0,0 +1 @@ +35000 35010 \ No newline at end of file diff --git a/Binaries/for_testing/splash.png b/Binaries/for_testing/splash.png new file mode 100644 index 0000000..d60c6fa Binary files /dev/null and b/Binaries/for_testing/splash.png differ diff --git a/EjemploKruskal.m b/EjemploKruskal.m new file mode 100644 index 0000000..01d3939 --- /dev/null +++ b/EjemploKruskal.m @@ -0,0 +1,24 @@ +% Cell con nombres de nodos +names = {'A', 'B', 'C', 'D', 'E', 'F', 'G'}; + +% Matriz de adyacencias +A = [0 2 3 3 0 0 0; +0 0 4 0 3 0 0; +0 0 0 5 1 0 0; +0 0 0 0 0 7 0; +0 0 0 0 0 8 0; +0 0 0 0 0 0 9; +0 0 0 0 0 0 0]; + +% Crear grafo no-dirigido, con pesos y nombres usando +% una matriz de adyacencias triangular superior +G = graph(A, names, 'upper'); + +% Crear visualización del grafo con los pesos en las etiquetas de las aristas +h = plot(G, 'EdgeLabel', G.Edges.Weight) + +% Usar algoritmo de Kruskal para obtener árbol generador de peso mínimo +T = MinimumSpanTree(G); + +% Sobresaltar aristas del árbol generador de peso mínimo +highlight(h, T, 'EdgeColor', 'r', 'LineWidth', 1.5) \ No newline at end of file diff --git a/Kruskal.prj b/Kruskal.prj new file mode 100644 index 0000000..3007561 --- /dev/null +++ b/Kruskal.prj @@ -0,0 +1,114 @@ + + + Kruskal + + + 1.0 + + + + + + + + \Kruskal\ + option.installpath.programfiles + + + + ${PROJECT_ROOT}\Kruskal\for_testing + ${PROJECT_ROOT}\Kruskal\for_redistribution_files_only + ${PROJECT_ROOT}\Kruskal\for_redistribution + ${PROJECT_ROOT}\Kruskal + false + + subtarget.standalone + + true + false + false + MyAppInstaller_web + MyAppInstaller_mcr + MyAppInstaller_app + true + false + + false + false + + Syntax + -? + + Input Arguments + -? print help on how to use the application + input arguments + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${PROJECT_ROOT}\KruskalAppEditor.mlapp + + + + + + C:\Users\esteb\Desktop\Kruskal\Kruskal\for_testing\readme.txt + C:\Users\esteb\Desktop\Kruskal\Kruskal\for_testing\Kruskal.exe + C:\Users\esteb\Desktop\Kruskal\Kruskal\for_testing\splash.png + + + + C:\Program Files\MATLAB\R2020a + + + + false + false + true + false + false + false + false + false + 10.0 + false + true + win64 + true + + + \ No newline at end of file diff --git a/KruskalAppEditor.mlapp b/KruskalAppEditor.mlapp new file mode 100644 index 0000000..ed2f374 Binary files /dev/null and b/KruskalAppEditor.mlapp differ diff --git a/MinimumSpanTree.m b/MinimumSpanTree.m new file mode 100644 index 0000000..f2ee5b8 --- /dev/null +++ b/MinimumSpanTree.m @@ -0,0 +1,79 @@ +function MST = MinimumSpanTree(Graph) + +% Iniciar Minimum Spanning Tree (MST) con arista de peso mínimo +MST = graph(); + +% Ordenar y obtener arista y peso de la arista del peso mínimo +minEdge = sortrows(Graph.Edges, 'Weight').EndNodes(1,:); +minWeight = sortrows(Graph.Edges, 'Weight').Weight(1,:); + +MST = MST.addedge(minEdge(1), minEdge(2), minWeight); + +% Eliminar vértice de Graph +Graph = Graph.rmedge(minEdge(1), minEdge(2)); + +% Mientras haya aristas en Graph, seguir iterando +while (~isempty(Graph.Edges)) + + % subgráfica de G adyacente a MST + subG = adjacentSubgraph(Graph, MST); + + % Arista de peso mínimo + minEdge = sortrows(subG.Edges, 'Weight').EndNodes(1,:); + minWeight = sortrows(subG.Edges, 'Weight').Weight(1,:); + + % Número de nodos de la arista que aparecen en el grafo + N = countNodes(MST, minEdge); + + % Si ninguno o sólo uno de los nodos aparecen, agregar + % la arista al árbol generador y borrarla de G + if N < 2 + MST = MST.addedge(minEdge(1), minEdge(2), minWeight); + end + + % Eliminar arista de G + Graph = Graph.rmedge(minEdge(1), minEdge(2)); +end + +end + + +function subG = adjacentSubgraph(G, F) +% Obtiene la subgráfica de G con las aristas que incluyen a nodos en F +% F es una subgráfica de G + +% Nodos de Graph y SubGraph +GNodes = unique(G.Edges.EndNodes); +FNodes = unique(F.Edges.EndNodes); + +% Intersección de nodos +Nodes = intersect(GNodes, FNodes); + +% Subgráfica resultante +subG = graph(); + +for i = 1:length(Nodes) + + % id's de aristas que incluyen a node + eid = G.outedges(Nodes(i)); + + % EdgeTable de las aristas que incluyen a node + tEdges = G.Edges(eid,:); + + % Agregar aristas elegidas a subGraph + subG = subG.addedge(tEdges); +end + +end + + +function n = countNodes(G, edge) +% Cuenta el número de nodos de la arista que están en el grafo + +% Conjunto de nodos en el grafo G +nodes = unique(G.Edges.EndNodes); + +% Devuelve el máximo número de veces +n = sum(ismember(edge, nodes)); + +end diff --git a/adjacencyMatrix.csv b/adjacencyMatrix.csv new file mode 100644 index 0000000..8b210d2 --- /dev/null +++ b/adjacencyMatrix.csv @@ -0,0 +1,7 @@ +0, 2, 3, 3, 0, 0, 0 +0, 0, 4, 0, 3, 0, 0 +0, 0, 0, 5, 1, 0, 0 +0, 0, 0, 0, 0, 7, 0 +0, 0, 0, 0, 0, 8, 0 +0, 0, 0, 0, 0, 0, 9 +0, 0, 0, 0, 0, 0, 0 \ No newline at end of file