From aca36aeb428152acb80905b3a35974e5a4dc277d Mon Sep 17 00:00:00 2001 From: Roberto Vasquez <86746480+hachi99@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:28:05 -0600 Subject: [PATCH 1/6] Create team folder Created team folder --- mpi4py_examples/team_MinecrafterosPro/placeholder.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 mpi4py_examples/team_MinecrafterosPro/placeholder.txt diff --git a/mpi4py_examples/team_MinecrafterosPro/placeholder.txt b/mpi4py_examples/team_MinecrafterosPro/placeholder.txt new file mode 100644 index 0000000..be9bd12 --- /dev/null +++ b/mpi4py_examples/team_MinecrafterosPro/placeholder.txt @@ -0,0 +1 @@ +ignore From f0ad103327ecf80c7e3cedb50336243526aad7c6 Mon Sep 17 00:00:00 2001 From: Roberto Vasquez <86746480+hachi99@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:30:13 -0600 Subject: [PATCH 2/6] Added new files for DFM and BFM algorithm searches These files correspond to the activity that was assigned on march 6 2024 team members: Roberto Vasquez Deniz Jesus Isaac Estrada Ramirez Haydee Josselyn Cortes Ubaldo --- .../team_MinecrafterosPro/AlgoritmoAnchura.py | 85 +++++++++++++++++++ .../AlgoritmoProfundidad.py | 74 ++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py create mode 100644 mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py diff --git a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py new file mode 100644 index 0000000..644d859 --- /dev/null +++ b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py @@ -0,0 +1,85 @@ +""" +Nombre del Módulo: Algoritmo en anchura +Autor: Roberto Vasquez Deniz, Jesus Isaac Estrada Ramirez, Haydee Josselyn Cortes Ubaldo +Fecha: 06 Marzo 2024 +Descripción: + Este modulo contiene un algoritmo de anchura en ejecucion normal (no paralelizado) + +Funciones: + def agregar_vertice(self, vertice): agrega vertices al grafo + def agregar_arista(self, vertice_origen, vertice_destino): Agrega una arista entre dos vértices + def bfs(self, vertice_inicial): Método de búsqueda en anchura (BFS) + + +Clases: + class Grafo: Instancia todo el programa +""" +# Importación de bibliotecas + +# Definición de constantes + +# Definición de funciones + +# Clase de grafo +class Grafo: + def __init__(self): + self.vertices = {} + + def agregar_vertice(self, vertice): + if vertice not in self.vertices: + self.vertices[vertice] = [] + + def agregar_arista(self, vertice_origen, vertice_destino): + if vertice_origen in self.vertices and vertice_destino in self.vertices: + self.vertices[vertice_origen].append(vertice_destino) + else: + print("Vertice origen o destino no encontrado.") + + def bfs(self, vertice_inicial): + visitados = set() + cola = [vertice_inicial] + + while cola: + vertice_actual = cola.pop(0) + if vertice_actual not in visitados: + print(vertice_actual) + visitados.add(vertice_actual) + for vecino in self.vertices[vertice_actual]: + if vecino not in visitados: + cola.append(vecino) + +# Código principal + +if __name__ == "__main__": + # Se inicializa el grafo + grafo = Grafo() + + # Agregamos los vértices + grafo.agregar_vertice('A') + grafo.agregar_vertice('B') + grafo.agregar_vertice('C') + grafo.agregar_vertice('D') + grafo.agregar_vertice('E') + grafo.agregar_vertice('F') + grafo.agregar_vertice('G') + grafo.agregar_vertice('H') + grafo.agregar_vertice('I') + grafo.agregar_vertice('J') + grafo.agregar_vertice('K') + + + # Agregamos las aristas + grafo.agregar_arista('A', 'B') + grafo.agregar_arista('A', 'C') + grafo.agregar_arista('B', 'D') + grafo.agregar_arista('K', 'E') + grafo.agregar_arista('C', 'F') + grafo.agregar_arista('F', 'G') + grafo.agregar_arista('G', 'H') + grafo.agregar_arista('H', 'I') + grafo.agregar_arista('H', 'J') + grafo.agregar_arista('I', 'K') + + # Realizamos la búsqueda en anchura desde el vértice 'A' + print("Recorrido en anchura (BFS):") + grafo.bfs('A') diff --git a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py new file mode 100644 index 0000000..daf30fb --- /dev/null +++ b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py @@ -0,0 +1,74 @@ +""" +Nombre del Módulo: Algoritmo en profundidad +Autor: Roberto Vasquez Deniz, Jesus Isaac Estrada Ramirez, Haydee Josselyn Cortes Ubaldo +Fecha: 06 Marzo 2024 +Descripción: + Este modulo contiene un algoritmo de profundidad en ejecucion normal (no paralelizado) + +Funciones: + def __init__(self): inicializa el grafo + def agregar_vertice(self, vertice): agrega vertices al grafo + def agregar_arista(self, vertice_origen, vertice_destino): Agrega una arista entre dos vértices + def dfs(self, vertice_inicial): Método de búsqueda en profundidad (DFS) + + +Clases: + class Grafo: Instancia todo el programa +""" +# Importación de bibliotecas + +# Definición de constantes + +# Definición de funciones + +# Clase de Grafo +class Grafo: + def __init__(self): + self.vertices = {} + + def agregar_vertice(self, vertice): + if vertice not in self.vertices: + self.vertices[vertice] = [] + + def agregar_arista(self, vertice_origen, vertice_destino): + if vertice_origen in self.vertices and vertice_destino in self.vertices: + self.vertices[vertice_origen].append(vertice_destino) + else: + print("Vertice origen o destino no encontrado.") + + def dfs(self, vertice_inicial): + visitados = set() + + def dfs_recursivo(vertice): + visitados.add(vertice) + print(vertice) + + for vecino in self.vertices[vertice]: + if vecino not in visitados: + dfs_recursivo(vecino) + + dfs_recursivo(vertice_inicial) + +# Código principal +if __name__ == "__main__": + # Se inicializa el grafo + grafo = Grafo() + + # Agregamos los vértices + grafo.agregar_vertice('A') + grafo.agregar_vertice('B') + grafo.agregar_vertice('C') + grafo.agregar_vertice('D') + grafo.agregar_vertice('E') + grafo.agregar_vertice('F') + + # Agregamos las aristas + grafo.agregar_arista('A', 'B') + grafo.agregar_arista('A', 'C') + grafo.agregar_arista('B', 'D') + grafo.agregar_arista('B', 'E') + grafo.agregar_arista('C', 'F') + + # Realizamos la búsqueda en profundidad desde el vértice 'A' + print("Recorrido en profundidad (DFS):") + grafo.dfs('A') From 27d8ad83b8a73968ead2da1f20ed5c2cab67e7d7 Mon Sep 17 00:00:00 2001 From: Roberto Vasquez Date: Wed, 6 Mar 2024 17:33:12 -0600 Subject: [PATCH 3/6] Revert "Create team folder" This reverts commit aca36aeb428152acb80905b3a35974e5a4dc277d. --- mpi4py_examples/team_MinecrafterosPro/placeholder.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 mpi4py_examples/team_MinecrafterosPro/placeholder.txt diff --git a/mpi4py_examples/team_MinecrafterosPro/placeholder.txt b/mpi4py_examples/team_MinecrafterosPro/placeholder.txt deleted file mode 100644 index be9bd12..0000000 --- a/mpi4py_examples/team_MinecrafterosPro/placeholder.txt +++ /dev/null @@ -1 +0,0 @@ -ignore From 2b06a4048fd687a01700493f9abd93afe7ff4e61 Mon Sep 17 00:00:00 2001 From: Roberto Vasquez Date: Wed, 6 Mar 2024 17:34:01 -0600 Subject: [PATCH 4/6] Revert "Added new files for DFM and BFM algorithm searches" This reverts commit f0ad103327ecf80c7e3cedb50336243526aad7c6. --- .../team_MinecrafterosPro/AlgoritmoAnchura.py | 85 ------------------- .../AlgoritmoProfundidad.py | 74 ---------------- 2 files changed, 159 deletions(-) delete mode 100644 mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py delete mode 100644 mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py diff --git a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py deleted file mode 100644 index 644d859..0000000 --- a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoAnchura.py +++ /dev/null @@ -1,85 +0,0 @@ -""" -Nombre del Módulo: Algoritmo en anchura -Autor: Roberto Vasquez Deniz, Jesus Isaac Estrada Ramirez, Haydee Josselyn Cortes Ubaldo -Fecha: 06 Marzo 2024 -Descripción: - Este modulo contiene un algoritmo de anchura en ejecucion normal (no paralelizado) - -Funciones: - def agregar_vertice(self, vertice): agrega vertices al grafo - def agregar_arista(self, vertice_origen, vertice_destino): Agrega una arista entre dos vértices - def bfs(self, vertice_inicial): Método de búsqueda en anchura (BFS) - - -Clases: - class Grafo: Instancia todo el programa -""" -# Importación de bibliotecas - -# Definición de constantes - -# Definición de funciones - -# Clase de grafo -class Grafo: - def __init__(self): - self.vertices = {} - - def agregar_vertice(self, vertice): - if vertice not in self.vertices: - self.vertices[vertice] = [] - - def agregar_arista(self, vertice_origen, vertice_destino): - if vertice_origen in self.vertices and vertice_destino in self.vertices: - self.vertices[vertice_origen].append(vertice_destino) - else: - print("Vertice origen o destino no encontrado.") - - def bfs(self, vertice_inicial): - visitados = set() - cola = [vertice_inicial] - - while cola: - vertice_actual = cola.pop(0) - if vertice_actual not in visitados: - print(vertice_actual) - visitados.add(vertice_actual) - for vecino in self.vertices[vertice_actual]: - if vecino not in visitados: - cola.append(vecino) - -# Código principal - -if __name__ == "__main__": - # Se inicializa el grafo - grafo = Grafo() - - # Agregamos los vértices - grafo.agregar_vertice('A') - grafo.agregar_vertice('B') - grafo.agregar_vertice('C') - grafo.agregar_vertice('D') - grafo.agregar_vertice('E') - grafo.agregar_vertice('F') - grafo.agregar_vertice('G') - grafo.agregar_vertice('H') - grafo.agregar_vertice('I') - grafo.agregar_vertice('J') - grafo.agregar_vertice('K') - - - # Agregamos las aristas - grafo.agregar_arista('A', 'B') - grafo.agregar_arista('A', 'C') - grafo.agregar_arista('B', 'D') - grafo.agregar_arista('K', 'E') - grafo.agregar_arista('C', 'F') - grafo.agregar_arista('F', 'G') - grafo.agregar_arista('G', 'H') - grafo.agregar_arista('H', 'I') - grafo.agregar_arista('H', 'J') - grafo.agregar_arista('I', 'K') - - # Realizamos la búsqueda en anchura desde el vértice 'A' - print("Recorrido en anchura (BFS):") - grafo.bfs('A') diff --git a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py b/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py deleted file mode 100644 index daf30fb..0000000 --- a/mpi4py_examples/team_MinecrafterosPro/AlgoritmoProfundidad.py +++ /dev/null @@ -1,74 +0,0 @@ -""" -Nombre del Módulo: Algoritmo en profundidad -Autor: Roberto Vasquez Deniz, Jesus Isaac Estrada Ramirez, Haydee Josselyn Cortes Ubaldo -Fecha: 06 Marzo 2024 -Descripción: - Este modulo contiene un algoritmo de profundidad en ejecucion normal (no paralelizado) - -Funciones: - def __init__(self): inicializa el grafo - def agregar_vertice(self, vertice): agrega vertices al grafo - def agregar_arista(self, vertice_origen, vertice_destino): Agrega una arista entre dos vértices - def dfs(self, vertice_inicial): Método de búsqueda en profundidad (DFS) - - -Clases: - class Grafo: Instancia todo el programa -""" -# Importación de bibliotecas - -# Definición de constantes - -# Definición de funciones - -# Clase de Grafo -class Grafo: - def __init__(self): - self.vertices = {} - - def agregar_vertice(self, vertice): - if vertice not in self.vertices: - self.vertices[vertice] = [] - - def agregar_arista(self, vertice_origen, vertice_destino): - if vertice_origen in self.vertices and vertice_destino in self.vertices: - self.vertices[vertice_origen].append(vertice_destino) - else: - print("Vertice origen o destino no encontrado.") - - def dfs(self, vertice_inicial): - visitados = set() - - def dfs_recursivo(vertice): - visitados.add(vertice) - print(vertice) - - for vecino in self.vertices[vertice]: - if vecino not in visitados: - dfs_recursivo(vecino) - - dfs_recursivo(vertice_inicial) - -# Código principal -if __name__ == "__main__": - # Se inicializa el grafo - grafo = Grafo() - - # Agregamos los vértices - grafo.agregar_vertice('A') - grafo.agregar_vertice('B') - grafo.agregar_vertice('C') - grafo.agregar_vertice('D') - grafo.agregar_vertice('E') - grafo.agregar_vertice('F') - - # Agregamos las aristas - grafo.agregar_arista('A', 'B') - grafo.agregar_arista('A', 'C') - grafo.agregar_arista('B', 'D') - grafo.agregar_arista('B', 'E') - grafo.agregar_arista('C', 'F') - - # Realizamos la búsqueda en profundidad desde el vértice 'A' - print("Recorrido en profundidad (DFS):") - grafo.dfs('A') From 26188cc7ef531208b1223d44c4f785995cc3e9bc Mon Sep 17 00:00:00 2001 From: Roberto Vasquez Date: Wed, 6 Mar 2024 17:34:55 -0600 Subject: [PATCH 5/6] Revert "Revert "Create team folder"" This reverts commit 27d8ad83b8a73968ead2da1f20ed5c2cab67e7d7. --- mpi4py_examples/team_MinecrafterosPro/placeholder.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 mpi4py_examples/team_MinecrafterosPro/placeholder.txt diff --git a/mpi4py_examples/team_MinecrafterosPro/placeholder.txt b/mpi4py_examples/team_MinecrafterosPro/placeholder.txt new file mode 100644 index 0000000..be9bd12 --- /dev/null +++ b/mpi4py_examples/team_MinecrafterosPro/placeholder.txt @@ -0,0 +1 @@ +ignore From 944178c41d87a8ccb1248aee39c55b9590f3044b Mon Sep 17 00:00:00 2001 From: Roberto Vasquez Date: Wed, 6 Mar 2024 17:36:46 -0600 Subject: [PATCH 6/6] Create bfs_dfs_algorithms.py Added new files for DFM and BFM algorithm searches These files correspond to the activity that was assigned on march 6 2024 team members: Roberto Vasquez Deniz Jesus Isaac Estrada Ramirez Haydee Josselyn Cortes Ubaldo --- .../bfs_dfs_algorithms.py | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 mpi4py_examples/team_MinecrafterosPro/bfs_dfs_algorithms.py diff --git a/mpi4py_examples/team_MinecrafterosPro/bfs_dfs_algorithms.py b/mpi4py_examples/team_MinecrafterosPro/bfs_dfs_algorithms.py new file mode 100644 index 0000000..537af24 --- /dev/null +++ b/mpi4py_examples/team_MinecrafterosPro/bfs_dfs_algorithms.py @@ -0,0 +1,111 @@ +""" +Nombre del Módulo: Algoritmos BFS Y DFS +Autor: Roberto Vasquez Deniz, Jesus Isaac Estrada Ramirez, Haydee Josselyn Cortes Ubaldo +Fecha: 06 Marzo 2024 +Descripción: + Este modulo contiene un algoritmo de profundidad en ejecucion normal (no paralelizado) + +Funciones: + def __init__(self): inicializa el grafo + def agregar_vertice(self, vertice): agrega vertices al grafo + def agregar_arista(self, vertice_origen, vertice_destino): Agrega una arista entre dos vértices + def dfs(self, vertice_inicial): Método de búsqueda en profundidad (DFS) + def bfs(self, vertice_inicial): Método de búsqueda en anchura (BFS) + def execution_time(funcion, *args, **kwargs): calcula el tiempo de ejecucion de la funcion + + +Clases: + class Grafo: Instancia todo el programa +""" +# Importación de bibliotecas +import time + +# Definición de constantes + +# Definición de funciones +def execution_time(funcion, *args, **kwargs): + inicio = time.time() + funcion(*args, **kwargs) + fin = time.time() + print(f'Tiempo de ejecución {funcion.__name__}: {fin - inicio} segundos') + +# Clase de Grafo +class Grafo: + def __init__(self): + self.vertices = {} + + def agregar_vertice(self, vertice): + if vertice not in self.vertices: + self.vertices[vertice] = [] + + def agregar_arista(self, vertice_origen, vertice_destino): + if vertice_origen in self.vertices and vertice_destino in self.vertices: + self.vertices[vertice_origen].append(vertice_destino) + else: + print("Vertice origen o destino no encontrado.") + + def dfs_method(self, vertice_inicial): + visitados = set() + + def dfs_recursivo(vertice): + visitados.add(vertice) + print(vertice) + + for vecino in self.vertices[vertice]: + if vecino not in visitados: + dfs_recursivo(vecino) + + dfs_recursivo(vertice_inicial) + + def bfs_method(self, vertice_inicial): + visitados = set() + cola = [vertice_inicial] + + while cola: + vertice_actual = cola.pop(0) + if vertice_actual not in visitados: + print(vertice_actual) + visitados.add(vertice_actual) + for vecino in self.vertices[vertice_actual]: + if vecino not in visitados: + cola.append(vecino) + +# Código principal +if __name__ == "__main__": + # Se inicializa el grafo + grafo = Grafo() + + # Agregamos los vértices + grafo.agregar_vertice('A') + grafo.agregar_vertice('B') + grafo.agregar_vertice('C') + grafo.agregar_vertice('D') + grafo.agregar_vertice('E') + grafo.agregar_vertice('F') + grafo.agregar_vertice('G') + grafo.agregar_vertice('H') + grafo.agregar_vertice('I') + grafo.agregar_vertice('J') + grafo.agregar_vertice('K') + + + # Agregamos las aristas + grafo.agregar_arista('A', 'B') + grafo.agregar_arista('A', 'C') + grafo.agregar_arista('B', 'D') + grafo.agregar_arista('K', 'E') + grafo.agregar_arista('C', 'F') + grafo.agregar_arista('F', 'G') + grafo.agregar_arista('G', 'H') + grafo.agregar_arista('H', 'I') + grafo.agregar_arista('H', 'J') + grafo.agregar_arista('I', 'K') + + # Realizamos la búsqueda en profundidad desde el vértice 'A' + print("Recorrido en profundidad (DFS):") + execution_time(grafo.dfs_method, 'A') + + + print("\nRecorrido en anchura (BFS):") + execution_time(grafo.bfs_method,'A') +