mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 20:28:10 +00:00
community[patch]: Added functions in NetworkxEntityGraph class (#17535)
- **Description:** 1. Added _clear_edges()_ and _get_number_of_nodes()_ functions in NetworkxEntityGraph class. 2. Added the above two function in graph_networkx_qa.ipynb documentation.
This commit is contained in:
parent
bfaa8c3048
commit
685d62b032
@ -298,12 +298,34 @@
|
|||||||
"id": "045796cf",
|
"id": "045796cf",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"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": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3 (ipykernel)",
|
"display_name": "Python 3.10.6 64-bit",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
@ -317,7 +339,12 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.12"
|
"version": "3.10.6"
|
||||||
|
},
|
||||||
|
"vscode": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
@ -135,6 +135,14 @@ class NetworkxEntityGraph:
|
|||||||
"""Clear the graph."""
|
"""Clear the graph."""
|
||||||
self._graph.clear()
|
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]:
|
def get_topological_sort(self) -> List[str]:
|
||||||
"""Get a list of entity names in the graph sorted by causal dependence."""
|
"""Get a list of entity names in the graph sorted by causal dependence."""
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
|
Loading…
Reference in New Issue
Block a user