修改属性图节点的层级结构,新增子父级关系
This commit is contained in:
@@ -39,4 +39,22 @@ class RAGPropertyGraphStore(SimplePropertyGraphStore):
|
||||
graph.nodes = kg_nodes
|
||||
graph.relations = kg_relations
|
||||
|
||||
return cls(graph)
|
||||
return cls(graph)
|
||||
|
||||
def save_networkx_graph(self, name: str = "kg.html") -> None:
|
||||
"""Display the graph store, useful for debugging."""
|
||||
import networkx as nx
|
||||
|
||||
G = nx.DiGraph()
|
||||
for node in self.graph.nodes.values():
|
||||
if isinstance(node,EntityNode):
|
||||
G.add_node(node.id, label=node.name)
|
||||
for triplet in self.graph.triplets:
|
||||
G.add_edge(triplet[0], triplet[2], label=triplet[1])
|
||||
|
||||
# save to html file
|
||||
from pyvis.network import Network
|
||||
|
||||
net = Network(notebook=False, directed=True)
|
||||
net.from_nx(G)
|
||||
net.write_html(name)
|
||||
Reference in New Issue
Block a user