🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
feat: Waleed Networkx integration (#1456)
waleedalzarooni937f70c65ffe
diff --git a/camel/toolkits/__init__.py b/camel/toolkits/__init__.pyindex 58a262e95..27cd2c8b1 100644--- a/camel/toolkits/__init__.py+++ b/camel/toolkits/__init__.py@@ -45,6 +45,7 @@ from .human_toolkit import HumanToolkitfrom .stripe_toolkit import StripeToolkitfrom .video_toolkit import VideoDownloaderToolkitfrom .dappier_toolkit import DappierToolkit+from .networkx_toolkit import NetworkXToolkitfrom .semantic_scholar_toolkit import SemanticScholarToolkitfrom .sympy_toolkit import SymPyToolkitfrom .mineru_toolkit import MinerUToolkit@@ -81,6 +82,7 @@ __all__ = ['MeshyToolkit','OpenBBToolkit','DappierToolkit',+ 'NetworkXToolkit','SemanticScholarToolkit','SymPyToolkit','MinerUToolkit',diff --git a/camel/toolkits/networkx_toolkit.py b/camel/toolkits/networkx_toolkit.pynew file mode 100644index 000000000..10aa692f1--- /dev/null+++ b/camel/toolkits/networkx_toolkit.py@@ -0,0 +1,240 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++import json+from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union++from camel.logger import get_logger+from camel.toolkits import FunctionTool+from camel.toolkits.base import BaseToolkit++logger = get_logger(__name__)+++class NetworkXToolkit(BaseToolkit):+ _nx = None # Class variable to store the networkx module++ @classmethod+ def _get_nx(cls):+ r"""Lazily import networkx module when needed."""+ if cls._nx is None:+ import networkx++ cls._nx = networkx+ return cls._nx++ def __init__(+ self,+ graph_type: Literal[+ 'graph', 'digraph', 'multigraph', 'multidigraph'+ ] = 'graph',+ ):+ r"""Initializes the NetworkX graph client.++ Args:+ graph_type (Literal['graph', 'digraph', 'multigraph',+ 'multidigraph']):+ Type of graph to create. Options are:+ - 'graph': Undirected graph+ - 'digraph': Directed graph+ - 'multigraph': Undirected graph with parallel edges+ - 'multidigraph': Directed graph with parallel edges+ (default: :obj:`'graph'`)+ """+ nx = self._get_nx()+ graph_types = {+ 'graph': nx.Graph,+ 'digraph': nx.DiGraph,+ 'multigraph': nx.MultiGraph,+ 'multidigraph': nx.MultiDiGraph,+ }+ graph_class = graph_types.get(graph_type.lower())+ if graph_class is None:+ raise ValueError(+ f"Invalid graph type: {graph_type}. Must be one "+ f"of: {list(graph_types.keys())}"+ )++ self.graph = graph_class()+ logger.info(f"Initialized NetworkX {graph_type} instance.")++ def add_node(self, node_id: str, **attributes: Any) -> None:+ r"""Adds a node to the graph.++ Args:+ node_id (str): The ID of the node.+ attributes (dict): Additional node attributes.+ """+ logger.info(f"Adding node: {node_id}, attributes: {attributes}")+ self.graph.add_node(node_id, **attributes)++ def add_edge(self, source: str, target: str, **attributes: Any) -> None:+ r"""Adds an edge to the graph.++ Args:+ source (str): Source node ID.+ target (str): Target node ID.+ attributes (dict): Additional edge attributes.+ """+ logger.info(+ f"Adding edge: {source} -> {target}, attributes: {attributes}"+ )+ self.graph.add_edge(source, target, **attributes)++ def get_nodes(self) -> List[str]:+ r"""Returns all nodes in the graph.++ Returns:+ List[str]: A list of node IDs.+ """+ logger.info("Fetching all nodes.")+ return list(self.graph.nodes)++ def get_edges(self) -> List[Tuple[str, str]]:+ r"""Returns all edges in the graph.++ Returns:+ List[Tuple[str, str]]: A list of edges as (source, target).+ """+ logger.info("Fetching all edges.")+ return list(self.graph.edges)++ def get_shortest_path(+ self,+ source: str,+ target: str,+ weight: Optional[Union[str, Callable]] = None,+ method: Literal['dijkstra', 'bellman-ford'] = 'dijkstra',+ ) -> List[str]:+ r"""Finds the shortest path between two nodes.++ Args:+ source (str): The source node ID.+ target (str): The target node ID.+ weight (None, str or function, optional): Edge weights/distances.+ If None, every edge has weight/distance/cost 1.+ If string, use this edge attribute as the edge weight.+ If function, the weight of an edge is the value returned by+ the function. The function must accept three positional+ arguments: the two endpoints and the edge attribute+ dictionary. (default: :obj:`None`)+ method (Literal['dijkstra', 'bellman-ford'], optional): Algorithm+ to compute the path. Ignored if weight is None. (default:+ :obj:`'dijkstra'`)++ Returns:+ List[str]: A list of nodes in the shortest path.+ """+ logger.info(+ f"Finding shortest path from '{source}' to '{target}' "+ f"using {method} algorithm"+ )+ try:+ nx = self._get_nx()+ path = nx.shortest_path(+ self.graph,+ source=source,+ target=target,+ weight=weight,+ method=method,+ )+ logger.debug(f"Found path: {' -> '.join(path)}")+ return path+ except nx.NetworkXNoPath:+ error_msg = f"No path exists between '{source}' and '{target}'"+ logger.error(error_msg)+ return [error_msg]+ except nx.NodeNotFound as e:+ error_msg = f"Node not found in graph: {e!s}"+ logger.error(error_msg)+ return [error_msg]++ def compute_centrality(self) -> Dict[str, float]:+ r"""Computes centrality measures for the graph.++ Returns:+ Dict[str, float]: Centrality values for each node.+ """+ logger.info("Computing centrality measures.")+ nx = self._get_nx()+ return nx.degree_centrality(self.graph)++ def serialize_graph(self) -> str:+ r"""Serializes the graph to a JSON string.++ Returns:+ str: The serialized graph in JSON format.+ """+ logger.info("Serializing the graph.")+ nx = self._get_nx()+ return json.dumps(nx.node_link_data(self.graph))++ def deserialize_graph(self, data: str) -> None:+ r"""Loads a graph from a serialized JSON string.++ Args:+ data (str): The JSON string representing the graph.+ """+ logger.info("Deserializing graph from JSON data.")+ nx = self._get_nx()+ self.graph = nx.node_link_graph(json.loads(data))++ def export_to_file(self, file_path: str) -> None:+ r"""Exports the graph to a file in JSON format.++ Args:+ file_path (str): The file path to save the graph.+ """+ logger.info(f"Exporting graph to file: {file_path}")+ nx = self._get_nx()+ with open(file_path, "w") as file:+ json.dump(nx.node_link_data(self.graph), file)++ def import_from_file(self, file_path: str) -> None:+ r"""Imports a graph from a JSON file.++ Args:+ file_path (str): The file path to load the graph from.+ """+ logger.info(f"Importing graph from file: {file_path}")+ nx = self._get_nx()+ with open(file_path, "r") as file:+ self.graph = nx.node_link_graph(json.load(file))++ def clear_graph(self) -> None:+ r"""Clears the current graph."""+ logger.info("Clearing the graph.")+ self.graph.clear()++ def get_tools(self) -> List[FunctionTool]:+ r"""Returns a list of FunctionTool objects representing the+ functions in the toolkit.++ Returns:+ List[FunctionTool]: A list of FunctionTool objects for the+ toolkit methods.+ """+ return [+ FunctionTool(self.add_edge),+ FunctionTool(self.add_node),+ FunctionTool(self.clear_graph),+ FunctionTool(self.compute_centrality),+ FunctionTool(self.deserialize_graph),+ FunctionTool(self.export_to_file),+ FunctionTool(self.get_edges),+ FunctionTool(self.get_nodes),+ FunctionTool(self.import_from_file),+ FunctionTool(self.serialize_graph),+ FunctionTool(self.get_shortest_path),+ ]diff --git a/examples/toolkits/networkx_toolkit.py b/examples/toolkits/networkx_toolkit.pynew file mode 100644index 000000000..b4fba86fb--- /dev/null+++ b/examples/toolkits/networkx_toolkit.py@@ -0,0 +1,72 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++from camel.agents import ChatAgent+from camel.configs.openai_config import ChatGPTConfig+from camel.models import ModelFactory+from camel.toolkits import NetworkXToolkit+from camel.types import ModelPlatformType, ModelType++# Define system message+sys_msg = "You are a helpful assistant for graph analysis"++# Set model config and initialize toolkit+tools = NetworkXToolkit(graph_type='digraph').get_tools()+model_config_dict = ChatGPTConfig(+ temperature=0.0,+).as_dict()++model = ModelFactory.create(+ model_platform=ModelPlatformType.DEFAULT,+ model_type=ModelType.DEFAULT,+ model_config_dict=model_config_dict,+)++# Set agent+camel_agent = ChatAgent(+ system_message=sys_msg,+ model=model,+ tools=tools,+)++# Example: Create a directed graph and perform some analysis+usr_msg = """Create a directed graph with the following edges:+- A -> B (weight: 2)+- B -> C (weight: 3)+- C -> A (weight: 1)+Then find the shortest path from A to C and calculate the graph density."""++# Get response information+response = camel_agent.step(usr_msg)+print(str(response.info['tool_calls']))++'''+===============================================================================+[ToolCallingRecord(tool_name='add_edge', args={'source': 'A', 'target': 'B'},+result=None, tool_call_id='call_iewKMXQd2GKwKWy7XJ5e5d8e'), ToolCallingRecord+(tool_name='add_edge', args={'source': 'A', 'target': 'B'}, result=None,+tool_call_id='call_Xn8wq22oKeKekuPEqcSj5HuJ'), ToolCallingRecord+(tool_name='add_edge', args={'source': 'B', 'target': 'C'}, result=None,+tool_call_id='call_bPeCvUBk1iQ6vv5060Zd7nbi'), ToolCallingRecord+(tool_name='add_edge', args={'source': 'C', 'target': 'A'}, result=None,+tool_call_id='call_inCnY60iSBVghsrrHEDh7hNw'), ToolCallingRecord+(tool_name='get_shortest_path', args={'source': 'A', 'target': 'C', 'weight':+'weight', 'method': 'dijkstra'}, result=['A', 'B', 'C'],+tool_call_id='call_Gwy3Ca8RDQCZFuiy2h0Z6SSF'), ToolCallingRecord+(tool_name='get_edges', args={}, result=[('A', 'B'), ('B', 'C'), ('C', 'A')],+tool_call_id='call_LU2xhb2W4h5a6LOx4U8gLuxa'), ToolCallingRecord+(tool_name='get_nodes', args={}, result=['A', 'B', 'C'],+tool_call_id='call_WLuB1nBrhFeGj4FKrbwfnCrG')]+===============================================================================+'''diff --git a/poetry.lock b/poetry.lockindex c1616074e..ef22d8864 100644--- a/poetry.lock+++ b/poetry.lock@@ -367,13 +367,13 @@ trio = ["trio (>=0.26.1)"][[package]]name = "apify-client"-version = "1.9.1"+version = "1.9.2"description = "Apify API client for Python"optional = truepython-versions = "<4.0,>=3.9"files = [- {file = "apify_client-1.9.1-py3-none-any.whl", hash = "sha256:7f1eaf0c66a077d47eb267f4af6a7ec53d10b683ea4c585daa2a2a01f7e74e3f"},- {file = "apify_client-1.9.1.tar.gz", hash = "sha256:aadaa5800845ca1c5b1c7416f23358cc1fcbd2aab035521e40235f33721e2a26"},+ {file = "apify_client-1.9.2-py3-none-any.whl", hash = "sha256:a441fb59b5ec1c42aead73284c90304029442ddc26e764c151b8dc7f15e38600"},+ {file = "apify_client-1.9.2.tar.gz", hash = "sha256:af76b78c3153263040615daec0619765e067466bbb82e569afe799ad72c53050"},][package.dependencies]@@ -748,13 +748,13 @@ css = ["tinycss2 (>=1.1.0,<1.5)"][[package]]name = "botocore"-version = "1.36.17"+version = "1.36.21"description = "Low-level, data-driven core of boto 3."optional = truepython-versions = ">=3.8"files = [- {file = "botocore-1.36.17-py3-none-any.whl", hash = "sha256:069858b2fd693548035d7fd53a774e37e4260fea64e0ac9b8a3aee904f9321df"},- {file = "botocore-1.36.17.tar.gz", hash = "sha256:cec13e0a7ce78e71aad0b397581b4e81824c7981ef4c261d2e296d200c399b09"},+ {file = "botocore-1.36.21-py3-none-any.whl", hash = "sha256:24a7052e792639dc2726001bd474cd0aaa959c1e18ddd92c17f3adc6efa1b132"},+ {file = "botocore-1.36.21.tar.gz", hash = "sha256:da746240e2ad64fd4997f7f3664a0a8e303d18075fc1d473727cb6375080ea16"},][package.dependencies]@@ -1444,21 +1444,21 @@ six = "*"[[package]]name = "datasets"-version = "3.2.0"+version = "3.3.0"description = "HuggingFace community-driven open-source library of datasets"optional = truepython-versions = ">=3.9.0"files = [- {file = "datasets-3.2.0-py3-none-any.whl", hash = "sha256:f3d2ba2698b7284a4518019658596a6a8bc79f31e51516524249d6c59cf0fe2a"},- {file = "datasets-3.2.0.tar.gz", hash = "sha256:9a6e1a356052866b5dbdd9c9eedb000bf3fc43d986e3584d9b028f4976937229"},+ {file = "datasets-3.3.0-py3-none-any.whl", hash = "sha256:22312d09626f8fc3aa0a237b0c164997f5903bddd4c4c9e27dbaf563754c681b"},+ {file = "datasets-3.3.0.tar.gz", hash = "sha256:54c607b06f6eaa1572e21e200d2870d89d50e3bcc622dc2021a53a6ce4f684c2"},][package.dependencies]aiohttp = "*"dill = ">=0.3.0,<0.3.9"filelock = "*"-fsspec = {version = ">=2023.1.0,<=2024.9.0", extras = ["http"]}-huggingface-hub = ">=0.23.0"+fsspec = {version = ">=2023.1.0,<=2024.12.0", extras = ["http"]}+huggingface-hub = ">=0.24.0"multiprocess = "<0.70.17"numpy = ">=1.17"packaging = "*"@@ -1472,15 +1472,15 @@ xxhash = "*"[package.extras]audio = ["librosa", "soundfile (>=0.12.1)", "soxr (>=0.4.0)"]benchmarks = ["tensorflow (==2.12.0)", "torch (==2.0.1)", "transformers (==4.30.1)"]-dev = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "faiss-cpu (>=1.8.0.post1)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "librosa", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "ruff (>=0.3.0)", "s3fs", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tensorflow (>=2.16.0)", "tensorflow (>=2.6.0)", "tensorflow (>=2.6.0)", "tiktoken", "torch", "torch (>=2.0.0)", "torchdata", "transformers", "transformers (>=4.42.0)", "zstandard"]+dev = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "faiss-cpu (>=1.8.0.post1)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "librosa", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "ruff (>=0.3.0)", "s3fs", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tensorflow (>=2.16.0)", "tensorflow (>=2.6.0)", "tensorflow (>=2.6.0)", "tiktoken", "torch", "torch (>=2.0.0)", "torchdata", "transformers", "transformers (>=4.42.0)", "zstandard"]docs = ["s3fs", "tensorflow (>=2.6.0)", "torch", "transformers"]jax = ["jax (>=0.3.14)", "jaxlib (>=0.3.14)"]quality = ["ruff (>=0.3.0)"]s3 = ["s3fs"]tensorflow = ["tensorflow (>=2.6.0)"]tensorflow-gpu = ["tensorflow (>=2.6.0)"]-tests = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "faiss-cpu (>=1.8.0.post1)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "librosa", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tensorflow (>=2.16.0)", "tensorflow (>=2.6.0)", "tiktoken", "torch (>=2.0.0)", "torchdata", "transformers (>=4.42.0)", "zstandard"]-tests-numpy2 = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tiktoken", "torch (>=2.0.0)", "torchdata", "transformers (>=4.42.0)", "zstandard"]+tests = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "faiss-cpu (>=1.8.0.post1)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "librosa", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tensorflow (>=2.16.0)", "tensorflow (>=2.6.0)", "tiktoken", "torch (>=2.0.0)", "torchdata", "transformers (>=4.42.0)", "zstandard"]+tests-numpy2 = ["Pillow (>=9.4.0)", "absl-py", "decorator", "decord (==0.6.0)", "elasticsearch (>=7.17.12,<8.0.0)", "jax (>=0.3.14)", "jaxlib (>=0.3.14)", "joblib (<1.3.0)", "joblibspark", "lz4", "moto[server]", "polars[timezone] (>=0.20.0)", "protobuf (<4.0.0)", "py7zr", "pyspark (>=3.4)", "pytest", "pytest-datadir", "pytest-xdist", "rarfile (>=4.0)", "s3fs (>=2021.11.1)", "soundfile (>=0.12.1)", "soundfile (>=0.12.1)", "soxr (>=0.4.0)", "sqlalchemy", "tiktoken", "torch (>=2.0.0)", "torchdata", "transformers (>=4.42.0)", "zstandard"]torch = ["torch"]vision = ["Pillow (>=9.4.0)"]@@ -2422,13 +2422,13 @@ files = [[[package]]name = "fsspec"-version = "2024.9.0"+version = "2024.12.0"description = "File-system specification"optional = falsepython-versions = ">=3.8"files = [- {file = "fsspec-2024.9.0-py3-none-any.whl", hash = "sha256:a0947d552d8a6efa72cc2c730b12c41d043509156966cca4fb157b0f2a0c574b"},- {file = "fsspec-2024.9.0.tar.gz", hash = "sha256:4b0afb90c2f21832df142f292649035d80b421f60a9e1c027802e5a0da2b04e8"},+ {file = "fsspec-2024.12.0-py3-none-any.whl", hash = "sha256:b520aed47ad9804237ff878b504267a3b0b441e97508bd6d2d8774e3db85cee2"},+ {file = "fsspec-2024.12.0.tar.gz", hash = "sha256:670700c977ed2fb51e0d9f9253177ed20cbde4a3e5c0283cc5385b5870c8533f"},][package.dependencies]@@ -2594,13 +2594,13 @@ tracing = ["opentelemetry-api (>=1.1.0)"][[package]]name = "google-cloud-vision"-version = "3.9.0"+version = "3.10.0"description = "Google Cloud Vision API client library"optional = truepython-versions = ">=3.7"files = [- {file = "google_cloud_vision-3.9.0-py2.py3-none-any.whl", hash = "sha256:9acec27ee05bd197f0d89c97e9719712ef245e0c37fd428e6af09a15a082fbef"},- {file = "google_cloud_vision-3.9.0.tar.gz", hash = "sha256:21226aac9cb4ba45bf89cc2e107aea19e4f78f9736eb1de56837e0c2989fecff"},+ {file = "google_cloud_vision-3.10.0-py2.py3-none-any.whl", hash = "sha256:cac9705a21374dcd4a62281e93dae5a2cb7eaf161fdd0aa5585e66c6c1d42f44"},+ {file = "google_cloud_vision-3.10.0.tar.gz", hash = "sha256:1f0b1e17ada68f7b257eef3cb7c91a02c8f21e254f8bdb8ff38b0e67d25ce3a5"},][package.dependencies]@@ -2668,13 +2668,13 @@ requests = ["requests (>=2.18.0,<3.0.0dev)"][[package]]name = "googleapis-common-protos"-version = "1.66.0"+version = "1.67.0"description = "Common protobufs used in Google APIs"optional = truepython-versions = ">=3.7"files = [- {file = "googleapis_common_protos-1.66.0-py2.py3-none-any.whl", hash = "sha256:d7abcd75fabb2e0ec9f74466401f6c119a0b498e27370e9be4c94cb7e382b8ed"},- {file = "googleapis_common_protos-1.66.0.tar.gz", hash = "sha256:c3e7b33d15fdca5374cc0a7346dd92ffa847425cc4ea941d970f13680052ec8c"},+ {file = "googleapis_common_protos-1.67.0-py2.py3-none-any.whl", hash = "sha256:579de760800d13616f51cf8be00c876f00a9f146d3e6510e19d1f4111758b741"},+ {file = "googleapis_common_protos-1.67.0.tar.gz", hash = "sha256:21398025365f138be356d5923e9168737d94d46a72aefee4a6110a1f23463c86"},][package.dependencies]@@ -3933,13 +3933,13 @@ pydantic = "*"[[package]]name = "litellm"-version = "1.61.0"+version = "1.61.6"description = "Library to easily interface with LLM API providers"optional = truepython-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"files = [- {file = "litellm-1.61.0-py3-none-any.whl", hash = "sha256:23b525c10bed385778b40eaa411809b12fb8795d9f52589f8336cabd09adb342"},- {file = "litellm-1.61.0.tar.gz", hash = "sha256:fad57052abcd32c9eab6915ca0c8b217931f5fada613ab07324dc8e03c4c4aab"},+ {file = "litellm-1.61.6-py3-none-any.whl", hash = "sha256:eef4c4a84a2c93de4c6d5a05a785f9b0cc61f63bafb3b3dc83d977db649e1b13"},+ {file = "litellm-1.61.6.tar.gz", hash = "sha256:2c613823f86ce2aa7956e2458857ab6aa62258dc7da9816bfdac90735be270be"},][package.dependencies]@@ -4673,13 +4673,13 @@ files = [[[package]]name = "myst-parser"-version = "4.0.0"+version = "4.0.1"description = "An extended [CommonMark](https://spec.commonmark.org/) compliant parser,"optional = falsepython-versions = ">=3.10"files = [- {file = "myst_parser-4.0.0-py3-none-any.whl", hash = "sha256:b9317997552424448c6096c2558872fdb6f81d3ecb3a40ce84a7518798f3f28d"},- {file = "myst_parser-4.0.0.tar.gz", hash = "sha256:851c9dfb44e36e56d15d05e72f02b80da21a9e0d07cba96baf5e2d476bb91531"},+ {file = "myst_parser-4.0.1-py3-none-any.whl", hash = "sha256:9134e88959ec3b5780aedf8a99680ea242869d012e8821db3126d427edc9c95d"},+ {file = "myst_parser-4.0.1.tar.gz", hash = "sha256:5cfea715e4f3574138aecbf7d54132296bfd72bb614d31168f48c477a830a7c4"},][package.dependencies]@@ -4691,10 +4691,10 @@ pyyaml = "*"sphinx = ">=7,<9"[package.extras]-code-style = ["pre-commit (>=3.0,<4.0)"]+code-style = ["pre-commit (>=4.0,<5.0)"]linkify = ["linkify-it-py (>=2.0,<3.0)"]rtd = ["ipython", "sphinx (>=7)", "sphinx-autodoc2 (>=0.5.0,<0.6.0)", "sphinx-book-theme (>=1.1,<2.0)", "sphinx-copybutton", "sphinx-design", "sphinx-pyscript", "sphinx-tippy (>=0.4.3)", "sphinx-togglebutton", "sphinxext-opengraph (>=0.9.0,<0.10.0)", "sphinxext-rediraffe (>=0.2.7,<0.3.0)"]-testing = ["beautifulsoup4", "coverage[toml]", "defusedxml", "pytest (>=8,<9)", "pytest-cov", "pytest-param-files (>=0.6.0,<0.7.0)", "pytest-regressions", "sphinx-pytest"]+testing = ["beautifulsoup4", "coverage[toml]", "defusedxml", "pygments (<2.19)", "pytest (>=8,<9)", "pytest-cov", "pytest-param-files (>=0.6.0,<0.7.0)", "pytest-regressions", "sphinx-pytest"]testing-docutils = ["pygments", "pytest (>=8,<9)", "pytest-param-files (>=0.6.0,<0.7.0)"][[package]]@@ -5303,13 +5303,13 @@ sympy = "*"[[package]]name = "openai"-version = "1.61.1"+version = "1.63.0"description = "The official Python library for the openai API"optional = falsepython-versions = ">=3.8"files = [- {file = "openai-1.61.1-py3-none-any.whl", hash = "sha256:72b0826240ce26026ac2cd17951691f046e5be82ad122d20a8e1b30ca18bd11e"},- {file = "openai-1.61.1.tar.gz", hash = "sha256:ce1851507218209961f89f3520e06726c0aa7d0512386f0f977e3ac3e4f2472e"},+ {file = "openai-1.63.0-py3-none-any.whl", hash = "sha256:a664dfc78f0a05ca46c3e21f344f840cf6bf7174f13cfa9de214ed28bfca1dda"},+ {file = "openai-1.63.0.tar.gz", hash = "sha256:597d7a1b35b113e5a09fcb953bdb1eef44f404a39985f3d7573b3ab09221fd66"},][package.dependencies]@@ -5622,13 +5622,13 @@ openbb-core = ">=1.4.0,<2.0.0"[[package]]name = "openbb-fixedincome"-version = "1.4.0"+version = "1.4.1"description = "Fixed income extension for OpenBB"optional = truepython-versions = "<4.0,>=3.9"files = [- {file = "openbb_fixedincome-1.4.0-py3-none-any.whl", hash = "sha256:bd9683ac6d66b4a9cd3b0923e96175752ef7925e69ccfd4e6f4e715fad01b52f"},- {file = "openbb_fixedincome-1.4.0.tar.gz", hash = "sha256:626d65d9aa288bd4db10e808c24bddd737c3fa36b8c8e8f5462cb8f947d15a86"},+ {file = "openbb_fixedincome-1.4.1-py3-none-any.whl", hash = "sha256:5c076a04bd77ba7a2e622c319255259fb447b2ce34d08419ebf2c6380e155336"},+ {file = "openbb_fixedincome-1.4.1.tar.gz", hash = "sha256:7f1825b92bd6fe100363a2c6f5ee47f23d6617db24db28ed182ce08ccd447d37"},][package.dependencies]@@ -6803,13 +6803,13 @@ tests = ["pytest (>=5.4.1)", "pytest-cov (>=2.8.1)", "pytest-mypy (>=0.8.0)", "p[[package]]name = "posthog"-version = "3.12.1"+version = "3.13.0"description = "Integrate PostHog into any python application."optional = truepython-versions = "*"files = [- {file = "posthog-3.12.1-py2.py3-none-any.whl", hash = "sha256:f749bb4aa4610678c3ea71e0f491cfb2dce570196b9753a04260ff08e52dfb6d"},- {file = "posthog-3.12.1.tar.gz", hash = "sha256:319036f83436981b3bdc750b0ed067b5439c510ed601933f8fc043d0989c73c6"},+ {file = "posthog-3.13.0-py2.py3-none-any.whl", hash = "sha256:0afd0132055a3da9c6b0ecf763e7f2ce2b66659ef16169883394d0835c30d501"},+ {file = "posthog-3.13.0.tar.gz", hash = "sha256:54e9de232459846b1686a0cfb58acb02b7ccda379d837e1eb1c3af62c3775915"},][package.dependencies]@@ -6820,10 +6820,10 @@ requests = ">=2.7,<3.0"six = ">=1.5"[package.extras]-dev = ["black", "flake8", "flake8-print", "isort", "pre-commit"]+dev = ["black", "django-stubs", "flake8", "flake8-print", "isort", "lxml", "mypy", "mypy-baseline", "pre-commit", "pydantic", "types-mock", "types-python-dateutil", "types-requests", "types-setuptools", "types-six"]langchain = ["langchain (>=0.2.0)"]sentry = ["django", "sentry-sdk"]-test = ["anthropic", "coverage", "django", "flake8", "freezegun (==0.3.15)", "langchain-anthropic (>=0.2.0)", "langchain-community (>=0.2.0)", "langchain-openai (>=0.2.0)", "langgraph", "mock (>=2.0.0)", "openai", "pydantic", "pylint", "pytest", "pytest-asyncio", "pytest-timeout"]+test = ["anthropic", "coverage", "django", "flake8", "freezegun (==1.5.1)", "langchain-anthropic (>=0.2.0)", "langchain-community (>=0.2.0)", "langchain-openai (>=0.2.0)", "langgraph", "mock (>=2.0.0)", "openai", "pydantic", "pylint", "pytest", "pytest-asyncio", "pytest-timeout"][[package]]name = "prance"@@ -7473,13 +7473,13 @@ files = [[[package]]name = "pygithub"-version = "2.5.0"+version = "2.6.0"description = "Use the full Github API v3"optional = truepython-versions = ">=3.8"files = [- {file = "PyGithub-2.5.0-py3-none-any.whl", hash = "sha256:b0b635999a658ab8e08720bdd3318893ff20e2275f6446fcf35bf3f44f2c0fd2"},- {file = "pygithub-2.5.0.tar.gz", hash = "sha256:e1613ac508a9be710920d26eb18b1905ebd9926aa49398e88151c1b526aad3cf"},+ {file = "PyGithub-2.6.0-py3-none-any.whl", hash = "sha256:22635b245b885413c607bb86393603cadcfdcb67a9b81ce9a64634e64f308084"},+ {file = "pygithub-2.6.0.tar.gz", hash = "sha256:04784fd6f4acfcaf91df5d3f08ef14153709395a34e706850f92337d9914548f"},][package.dependencies]@@ -9196,13 +9196,13 @@ type = ["importlib_metadata (>=7.0.2)", "jaraco.develop (>=7.21)", "mypy (==1.14[[package]]name = "sglang"-version = "0.4.2.post4"+version = "0.4.3"description = "SGLang is yet another fast serving framework for large language models and vision language models."optional = truepython-versions = ">=3.8"files = [- {file = "sglang-0.4.2.post4-py3-none-any.whl", hash = "sha256:33d6cec30ed4bd4e1a3d5b8dca4f6d932c0e607ff680eb3e3da3e14b7e861c9a"},- {file = "sglang-0.4.2.post4.tar.gz", hash = "sha256:d93ba43eccb91c679cd05a7b8339a88a35dafd7c736f84d52c458b6267178906"},+ {file = "sglang-0.4.3-py3-none-any.whl", hash = "sha256:2ce4a5385a0319fe70c2087b3def17ccb174deab1be1d4448eed430b3066d60b"},+ {file = "sglang-0.4.3.tar.gz", hash = "sha256:cea0a78a7d7e00c50b9a5ba0591509e3a7da3f4fd1eac1852457b9271ed0f2cb"},][package.dependencies]@@ -9226,8 +9226,8 @@ dev-hpu = ["sglang[all-hpu]", "sglang[test]"]dev-xpu = ["sglang[all-xpu]", "sglang[test]"]litellm = ["litellm (>=1.0.0)"]openai = ["openai (>=1.0)", "tiktoken"]-runtime-common = ["aiohttp", "decord", "fastapi", "hf_transfer", "huggingface_hub", "interegular", "modelscope", "orjson", "packaging", "pillow", "prometheus-client (>=0.20.0)", "psutil", "pydantic", "python-multipart", "pyzmq (>=25.1.2)", "torchao (>=0.7.0)", "uvicorn", "uvloop", "xgrammar (>=0.1.10)"]-srt = ["cuda-python", "flashinfer_python (>=0.2.0.post2)", "outlines (>=0.0.44,<=0.1.11)", "sgl-kernel (>=0.0.3.post3)", "sglang[runtime-common]", "torch", "vllm (>=0.6.4.post1,<=0.7.2)"]+runtime-common = ["aiohttp", "decord", "fastapi", "hf_transfer", "huggingface_hub", "interegular", "modelscope", "ninja", "orjson", "packaging", "pillow", "prometheus-client (>=0.20.0)", "psutil", "pydantic", "python-multipart", "pyzmq (>=25.1.2)", "torchao (>=0.7.0)", "uvicorn", "uvloop", "xgrammar (>=0.1.10)"]+srt = ["cuda-python", "flashinfer_python (>=0.2.1.post1)", "outlines (>=0.0.44,<=0.1.11)", "sgl-kernel (>=0.0.3.post6)", "sglang[runtime-common]", "torch", "vllm (>=0.6.4.post1,<=0.7.2)"]srt-cpu = ["outlines (>=0.0.44,<0.1.0)", "sglang[runtime-common]", "torch"]srt-hip = ["outlines (==0.1.11)", "sgl-kernel (>=0.0.3.post1)", "sglang[runtime-common]", "torch", "vllm (==0.6.7.dev2)"]srt-hpu = ["outlines (>=0.0.44,<0.1.0)", "sglang[runtime-common]"]@@ -10581,13 +10581,13 @@ core = ["tree-sitter (>=0.22,<1.0)"][[package]]name = "trio"-version = "0.28.0"+version = "0.29.0"description = "A friendly Python library for async concurrency and I/O"optional = truepython-versions = ">=3.9"files = [- {file = "trio-0.28.0-py3-none-any.whl", hash = "sha256:56d58977acc1635735a96581ec70513cc781b8b6decd299c487d3be2a721cd94"},- {file = "trio-0.28.0.tar.gz", hash = "sha256:4e547896fe9e8a5658e54e4c7c5fa1db748cbbbaa7c965e7d40505b928c73c05"},+ {file = "trio-0.29.0-py3-none-any.whl", hash = "sha256:d8c463f1a9cc776ff63e331aba44c125f423a5a13c684307e828d930e625ba66"},+ {file = "trio-0.29.0.tar.gz", hash = "sha256:ea0d3967159fc130acb6939a0be0e558e364fee26b5deeecc893a6b08c361bdf"},][package.dependencies]@@ -10830,13 +10830,13 @@ files = [[[package]]name = "tzlocal"-version = "5.2"+version = "5.3"description = "tzinfo object for the local timezone"optional = true-python-versions = ">=3.8"+python-versions = ">=3.9"files = [- {file = "tzlocal-5.2-py3-none-any.whl", hash = "sha256:49816ef2fe65ea8ac19d19aa7a1ae0551c834303d5014c6d5a62e4cbda8047b8"},- {file = "tzlocal-5.2.tar.gz", hash = "sha256:8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e"},+ {file = "tzlocal-5.3-py3-none-any.whl", hash = "sha256:3814135a1bb29763c6e4f08fd6e41dbb435c7a60bfbb03270211bcc537187d8c"},+ {file = "tzlocal-5.3.tar.gz", hash = "sha256:2fafbfc07e9d8b49ade18f898d6bcd37ae88ce3ad6486842a2e4f03af68323d2"},][package.dependencies]@@ -11711,20 +11711,18 @@ propcache = ">=0.2.0"[[package]]name = "yfinance"-version = "0.2.52"+version = "0.2.53"description = "Download market data from Yahoo! Finance API"optional = truepython-versions = "*"files = [- {file = "yfinance-0.2.52-py2.py3-none-any.whl", hash = "sha256:3ca150da85f56b999687e13b72304338499a417d5bad6af9da2aa13821992bd7"},- {file = "yfinance-0.2.52.tar.gz", hash = "sha256:d2c2ed9bc935596934cba99fca0f05beaa8384648f78105c77754e92f11bf72f"},+ {file = "yfinance-0.2.53-py2.py3-none-any.whl", hash = "sha256:529626244ebcfe0185d2cfdab120b5534b493c007f58722c16f4e4da55386b5b"},+ {file = "yfinance-0.2.53.tar.gz", hash = "sha256:2364c787eb9096f768014ca84175b6d9ccd1656bc252eb0698bd991352536b6a"},][package.dependencies]beautifulsoup4 = ">=4.11.1"frozendict = ">=2.3.4"-html5lib = ">=1.1"-lxml = ">=4.9.1"multitasking = ">=0.0.7"numpy = ">=1.16.5"pandas = ">=1.3.0"@@ -11778,9 +11776,9 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools",type = ["pytest-mypy"][extras]-all = ["PyMuPDF", "accelerate", "agentops", "aiosqlite", "anthropic", "apify_client", "arxiv", "arxiv2text", "asknews", "azure-storage-blob", "beautifulsoup4", "botocore", "cohere", "dappier", "datacommons", "datacommons_pandas", "datasets", "diffusers", "discord.py", "docker", "docx2txt", "duckduckgo-search", "e2b-code-interpreter", "ffmpeg-python", "firecrawl-py", "fish-audio-sdk", "google-cloud-storage", "googlemaps", "imageio", "ipykernel", "jupyter_client", "linkup-sdk", "litellm", "mistralai", "nebula3-python", "neo4j", "newspaper3k", "notion-client", "openapi-spec-validator", "openbb", "opencv-python", "outlines", "pandas", "pandasai", "pillow", "prance", "praw", "pyTelegramBotAPI", "pydub", "pygithub", "pymilvus", "pyowm", "qdrant-client", "rank-bm25", "redis", "reka-api", "requests_oauthlib", "rouge", "scholarly", "sentence-transformers", "sentencepiece", "sglang", "slack-bolt", "slack-sdk", "soundfile", "stripe", "sympy", "tavily-python", "textblob", "torch", "torch", "transformers", "tree-sitter", "tree-sitter-python", "unstructured", "wikipedia", "wolframalpha", "yt-dlp"]+all = ["PyMuPDF", "accelerate", "agentops", "aiosqlite", "anthropic", "apify_client", "arxiv", "arxiv2text", "asknews", "azure-storage-blob", "beautifulsoup4", "botocore", "cohere", "dappier", "datacommons", "datacommons_pandas", "datasets", "diffusers", "discord.py", "docker", "docx2txt", "duckduckgo-search", "e2b-code-interpreter", "ffmpeg-python", "firecrawl-py", "fish-audio-sdk", "google-cloud-storage", "googlemaps", "imageio", "ipykernel", "jupyter_client", "linkup-sdk", "litellm", "mistralai", "nebula3-python", "neo4j", "networkx", "newspaper3k", "notion-client", "openapi-spec-validator", "openbb", "opencv-python", "outlines", "pandas", "pandasai", "pillow", "prance", "praw", "pyTelegramBotAPI", "pydub", "pygithub", "pymilvus", "pyowm", "qdrant-client", "rank-bm25", "redis", "reka-api", "requests_oauthlib", "rouge", "scholarly", "sentence-transformers", "sentencepiece", "sglang", "slack-bolt", "slack-sdk", "soundfile", "stripe", "sympy", "tavily-python", "textblob", "torch", "torch", "transformers", "tree-sitter", "tree-sitter-python", "unstructured", "wikipedia", "wolframalpha", "yt-dlp"]communication-tools = ["discord.py", "notion-client", "praw", "pyTelegramBotAPI", "pygithub", "slack-bolt", "slack-sdk"]-data-tools = ["aiosqlite", "datacommons", "datacommons_pandas", "openbb", "pandas", "rouge", "stripe", "textblob"]+data-tools = ["aiosqlite", "datacommons", "datacommons_pandas", "networkx", "openbb", "pandas", "rouge", "stripe", "textblob"]dev-tools = ["agentops", "docker", "e2b-code-interpreter", "ipykernel", "jupyter_client", "tree-sitter", "tree-sitter-python"]document-tools = ["PyMuPDF", "beautifulsoup4", "docx2txt", "openapi-spec-validator", "pandasai", "prance", "unstructured"]huggingface = ["accelerate", "datasets", "diffusers", "opencv-python", "sentencepiece", "soundfile", "torch", "torch", "transformers"]@@ -11795,4 +11793,4 @@ web-tools = ["apify_client", "asknews", "dappier", "duckduckgo-search", "firecra[metadata]lock-version = "2.0"python-versions = ">=3.10,<3.13"-content-hash = "3711203293be46a711727d6c4cb8cb273a41e10e3f7231de38b234af7aa89368"+content-hash = "388dc65e92f5c3a038a38c32848025505a6afd5e7dd793015ebb809c27c80b06"diff --git a/pyproject.toml b/pyproject.tomlindex 7f42d885d..4179e19eb 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -130,6 +130,8 @@ datacommons_pandas = { version = "^0.0.3", optional = true }pandas = { version = "^1.5.3", optional = true }openbb = { version = "^4.3.5", optional = true }stripe = { version = "^11.3.0", optional = true }+networkx = { version = "^3.4.2", optional = true }+# Research toolsscholarly = { extras = ["tor"], version = "1.7.11", optional = true }@@ -227,6 +229,7 @@ data_tools = ["aiosqlite","openbb","stripe",+ "networkx",]# Academic and research tools@@ -347,6 +350,7 @@ all = ["tree-sitter-python","tree-sitter","openbb",+ "networkx","qdrant-client","pymilvus","cohere",@@ -535,6 +539,7 @@ module = ["pandas","tree-sitter-python","tree-sitter",+ "networkx","pandasai","sklearn.metrics.pairwise","sympy",diff --git a/test/toolkits/test_networkx_toolkit.py b/test/toolkits/test_networkx_toolkit.pynew file mode 100644index 000000000..a91e77169--- /dev/null+++ b/test/toolkits/test_networkx_toolkit.py@@ -0,0 +1,100 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import unittest++from camel.toolkits import NetworkXToolkit+++class TestNetworkXToolkit(unittest.TestCase):+ def setUp(self):+ self.graph = NetworkXToolkit()++ def test_add_node(self):+ self.graph.add_node("A", attr1="value1")+ nodes = self.graph.get_nodes()+ self.assertIn("A", nodes)++ def test_add_edge(self):+ self.graph.add_node("A")+ self.graph.add_node("B")+ self.graph.add_edge("A", "B", weight=2)+ edges = self.graph.get_edges()+ self.assertIn(("A", "B"), edges)++ def test_get_nodes(self):+ self.graph.add_node("A")+ self.graph.add_node("B")+ nodes = self.graph.get_nodes()+ self.assertListEqual(nodes, ["A", "B"])++ def test_get_edges(self):+ self.graph.add_node("A")+ self.graph.add_node("B")+ self.graph.add_edge("A", "B")+ edges = self.graph.get_edges()+ self.assertListEqual(edges, [("A", "B")])++ def test_shortest_path(self):+ self.graph.add_edge("A", "B")+ self.graph.add_edge("B", "C")+ path = self.graph.get_shortest_path("A", "C")+ self.assertListEqual(path, ["A", "B", "C"])++ def test_shortest_path_no_path(self):+ self.graph.add_node("A")+ self.graph.add_node("C")+ path = self.graph.get_shortest_path("A", "C")+ self.assertListEqual(path, ["No path exists between 'A' and 'C'"])++ def test_compute_centrality(self):+ self.graph.add_edge("A", "B")+ self.graph.add_edge("B", "C")+ centrality = self.graph.compute_centrality()+ expected_centrality = {"A": 0.5, "B": 1.0, "C": 0.5}+ self.assertEqual(centrality, expected_centrality)++ def test_serialize_graph(self):+ self.graph.add_edge("A", "B")+ serialized = self.graph.serialize_graph()+ self.assertIsInstance(serialized, str)++ def test_deserialize_graph(self):+ data = """{"directed": false, "multigraph": false, "graph": {},+ "nodes": [{"id": "A"}, {"id": "B"}],+ "links": [{"source": "A", "target": "B"}]}"""+ self.graph.deserialize_graph(data)+ nodes = self.graph.get_nodes()+ edges = self.graph.get_edges()+ self.assertListEqual(nodes, ["A", "B"])+ self.assertListEqual(edges, [("A", "B")])++ def test_export_import_file(self):+ file_path = "test_graph.json"+ self.graph.add_edge("A", "B")+ self.graph.export_to_file(file_path)++ new_graph = NetworkXToolkit()+ new_graph.import_from_file(file_path)+ self.assertListEqual(new_graph.get_nodes(), ["A", "B"])+ self.assertListEqual(new_graph.get_edges(), [("A", "B")])++ def test_clear_graph(self):+ self.graph.add_edge("A", "B")+ self.graph.clear_graph()+ self.assertListEqual(self.graph.get_nodes(), [])+ self.assertListEqual(self.graph.get_edges(), [])+++if __name__ == "__main__":+ unittest.main()