🔥 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:
parent
64397d2830
commit
585aeeab6e
1 changed files with 1 additions and 3 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue