知识图谱可视化系统源码分享


前后端分离架构

  • 前端:vue3 + antd-design-vue
  • 后端:python

系统功能

  • 登录
  • 注册
  • 知识图谱可视化
  • 智能问答
  • 图谱数据维护
  • 用户管理

可定制开发其它功能

代码设计规范,好修改,数据可轻松替换,便于复用

python 复制代码
if __name__ == '__main__':
    # 清空数据库中的所有数据
    graph.delete_all()
    files = loop_files('result', 'json')
    if files:
        data_list = []
        for file in files:
            file_name = os.path.basename(file)
            with open(file, 'r', encoding='utf-8') as file:
                content = file.read()
            content_list = []
            try:
                content_list = json.loads(content)
            except Exception as e:
                print(f"文件解析失败:{file}", e)
            if content_list:
                data_list.extend(content_list)
        # 保存数据到neo4j
        save_to_neo(data_list)
python 复制代码
    def get_kg_new(self, entity):
        conditions = []
        if entity:
            conditions.append(f"n.name =~ '.*{entity}.*'")
        where_clause = " AND ".join(conditions)
        where_clause = f"WHERE {where_clause}" if where_clause else ""
        sql = f"""
                   MATCH p=(n)-[r]-(m)
                   {where_clause}
                   RETURN nodes(p) AS nodes, relationships(p) AS rels limit 100
                   """
        print("查询节点:" + sql)
        result = self.graph.run(sql).data()
        nodes = []
        lines = []
        id_list = []

        if result:
            for record in result:
                for node in record['nodes']:
                    node_id = node.identity
                    if node_id not in id_list:
                        node_data = {
                            'id': node_id,
                            'name': node['name'],
                            'type': list(node.labels)[0] if node.labels else ''
                        }
                        for prop in node:
                            node_data[prop] = node[prop]
                        id_list.append(node_id)
                        nodes.append(node_data)

                for rel in record['rels']:
                    lines.append({
                        'from': rel.start_node.identity,
                        'to': rel.end_node.identity,
                        'text': type(rel).__name__
                    })

        json_data = {'nodes': nodes, 'lines': lines}
        return json_data

完整源码可获取,可远程部署答疑

相关推荐
在所不辞兄几秒前
分层PINN提升多物理场一致性
人工智能·神经网络·算法·机器学习·工程仿真
林伽一3 分钟前
从2048并发会话到501B开源模型,算力账本开始按“单位卡产出“计价|2026年10月07日
人工智能·安全·ai·开源
桃西西呀4 分钟前
Spring AI Alibaba 之一:整体概览与分层架构,看清它在 Spring AI 之上到底加了什么
人工智能·spring·llm
winfredzhang8 分钟前
用 Chrome 插件 + 局域网 Qwen2.5-VL 打造视频截屏 OCR 工具
人工智能·chrome·ocr·api·plugin
做cv的小昊10 分钟前
【大模型算法自学笔记01】NLP基础知识(1.1 自注意力)
人工智能·笔记·算法·自然语言处理·大模型·llm
loulanyue_13 分钟前
Context Is All You Need:读千问办公CEO陈宇森2026云栖演讲
人工智能·智能体·千问办公
零基础12313 分钟前
深度强化学习驱动的 Agent 后训练:原理、实践与前沿路线
人工智能·python·机器学习
一缕82年的清风14 分钟前
从 Cursor 杀回命令行:当 AI 接管终端,CLI 会取代 IDE 吗?
人工智能
夏文强18 分钟前
国产开源反攻海外:GLM-5.3 进 Cursor,CursorBench 开放权重第一
人工智能·开源·大模型·glm·智谱
Yyyyyy~19 分钟前
【机器学习】Numpy
人工智能·机器学习·numpy