Added search mode and min degree filtering for NetworkX

- Implemented exact and inclusive search modes
- Added min degree filtering for nodes
- Updated API to parse label for search options
This commit is contained in:
yangdx
2025-03-04 16:08:05 +08:00
parent 735231d851
commit 002948d342
3 changed files with 70 additions and 7 deletions

View File

@@ -504,10 +504,24 @@ class LightRAG:
return text
async def get_knowledge_graph(
self, node_label: str, max_depth: int
self, node_label: str, max_depth: int, search_mode: str = "exact", min_degree: int = 0
) -> KnowledgeGraph:
"""Get knowledge graph for a given label
Args:
node_label (str): Label to get knowledge graph for
max_depth (int): Maximum depth of graph
search_mode (str, optional): Search mode, either "exact" or "inclusive". Defaults to "exact".
min_degree (int, optional): Minimum degree of nodes to include. Defaults to 0.
Returns:
KnowledgeGraph: Knowledge graph containing nodes and edges
"""
return await self.chunk_entity_relation_graph.get_knowledge_graph(
node_label=node_label, max_depth=max_depth
node_label=node_label,
max_depth=max_depth,
search_mode=search_mode,
min_degree=min_degree
)
def _get_storage_class(self, storage_name: str) -> Callable[..., Any]: