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


前后端分离架构

  • 前端: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

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

相关推荐
追光者♂几秒前
【测评系列6】CSDN AI数字营销实测体验官——OpenClaw 数据采集工具新手入门指南
人工智能·深度学习·机器学习·ai·大模型·openclaw·前沿科学
OpenVINO 中文社区几秒前
AI PC上跑起 Qwen3.6-35B-A3B:OpenVINO™ 2026.2 带来本地多模态大模型新体验
人工智能·ai pc
jiayong23几秒前
ZeroClaw 可优化空间与改进建议
人工智能·ai·智能体·zeroclaw
Mr数据杨1 分钟前
【CanMV K210】传感器实验 霍尔传感器磁场方向与强度检测
人工智能·硬件开发·canmv k210
yubo05092 分钟前
计算机视觉第九课:颜色 + 形状 联合识别
人工智能·计算机视觉
czzxxxxxx2 分钟前
知识IP卡在变现第一步:创客匠人用一套陪跑系统回答“谁来陪你落地”
大数据·人工智能
jiayong233 分钟前
ZeroClaw 使用方式与启动指南
人工智能·ai·智能体·zeroclaw
有来有去95273 分钟前
【模型评测】SWE-bench Verified数据集-1-配置评测任务
人工智能·深度学习·语言模型
Lsland..4 分钟前
AI Agent到底是什么
java·人工智能·llm
Akamai中国4 分钟前
针对 Akamai Cloud 上的 NVIDIA RTX Pro 6000 Blackwell 进行基准测试
人工智能·云计算·gpu算力·云服务