From ad1edf60927e884b2ad0a4a4220abd6fb779a4b0 Mon Sep 17 00:00:00 2001 From: geekan Date: Wed, 31 Jan 2024 17:36:04 +0800 Subject: [PATCH] refine comments --- metagpt/actions/action_graph.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/metagpt/actions/action_graph.py b/metagpt/actions/action_graph.py index 8570778c7..893bc6d4c 100644 --- a/metagpt/actions/action_graph.py +++ b/metagpt/actions/action_graph.py @@ -11,7 +11,7 @@ from __future__ import annotations class ActionGraph: - """ActionGraph: 用于定义一个图,图中的节点是 ActionNode 实例,节点间的依赖关系是有向边。""" + """ActionGraph: a directed graph to represent the dependency between actions.""" def __init__(self): self.nodes = {} @@ -19,18 +19,11 @@ class ActionGraph: self.execution_order = [] def add_node(self, node): - """ - 添加一个节点到图中。 - :param node: ActionNode 实例 - """ + """Add a node to the graph""" self.nodes[node.key] = node def add_edge(self, from_node: "ActionNode", to_node: "ActionNode"): - """ - 定义节点间的依赖关系。 - :param from_node: 节点标识 - :param to_node: 节点标识 - """ + """Add an edge to the graph""" if from_node.key not in self.edges: self.edges[from_node.key] = [] self.edges[from_node.key].append(to_node.key) @@ -38,9 +31,7 @@ class ActionGraph: to_node.add_prev(from_node) def topological_sort(self): - """ - 实现拓扑排序来确定执行顺序。 - """ + """Topological sort the graph""" visited = set() stack = []