🔥 refactor(base.py): remove unnecessary build method call in Graph class

The build method call in the for loop of the build_vertices method is unnecessary as the vertices are already sorted and built in the topological_sort method. The yield from statement is used to return the sorted vertices.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-12 13:05:27 -03:00
commit 585aeeab6e

View file

@ -147,9 +147,7 @@ class Graph:
"""Builds each vertex in the graph and yields it."""
sorted_vertices = self.topological_sort()
logger.info("Sorted vertices: %s", sorted_vertices)
for node in sorted_vertices:
node.build()
yield node._built_object_repr(), node.id
yield from sorted_vertices
def get_node_neighbors(self, node: Vertex) -> Dict[Vertex, int]:
"""Returns the neighbors of a node."""