The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: Added functions in NetworkxEntityGraph class (#17535)
Raunak685d62b03247
diff --git a/docs/docs/use_cases/graph/graph_networkx_qa.ipynb b/docs/docs/use_cases/graph/graph_networkx_qa.ipynbindex cb70b8718c..a01d7c1127 100644--- a/docs/docs/use_cases/graph/graph_networkx_qa.ipynb+++ b/docs/docs/use_cases/graph/graph_networkx_qa.ipynb@@ -298,12 +298,34 @@"id": "045796cf","metadata": {},"outputs": [],- "source": []+ "source": [+ "loaded_graph.get_number_of_nodes()"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "d24b3407",+ "metadata": {},+ "outputs": [],+ "source": [+ "loaded_graph.clear_edges()"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "b8afda51",+ "metadata": {},+ "outputs": [],+ "source": [+ "loaded_graph.clear()"+ ]}],"metadata": {"kernelspec": {- "display_name": "Python 3 (ipykernel)",+ "display_name": "Python 3.10.6 64-bit","language": "python","name": "python3"},@@ -317,7 +339,12 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.10.12"+ "version": "3.10.6"+ },+ "vscode": {+ "interpreter": {+ "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"+ }}},"nbformat": 4,diff --git a/libs/community/langchain_community/graphs/networkx_graph.py b/libs/community/langchain_community/graphs/networkx_graph.pyindex 81b7862fab..ccc0bdad66 100644--- a/libs/community/langchain_community/graphs/networkx_graph.py+++ b/libs/community/langchain_community/graphs/networkx_graph.py@@ -135,6 +135,14 @@ class NetworkxEntityGraph:"""Clear the graph."""self._graph.clear()+ def clear_edges(self) -> None:+ """Clear the graph edges."""+ self._graph.clear_edges()++ def get_number_of_nodes(self) -> int:+ """Get number of nodes in the graph."""+ return self._graph.number_of_nodes()+def get_topological_sort(self) -> List[str]:"""Get a list of entity names in the graph sorted by causal dependence."""import networkx as nx