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.
pull/17526/head
Raunak 5 months ago committed by GitHub
parent bfaa8c3048
commit 685d62b032
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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,

@ -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

Loading…
Cancel
Save