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


前后端分离架构

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

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

相关推荐
fightcrap6 分钟前
DeepSeek Harness:Cordis 插件树与 Agent 主链路
人工智能·后端·程序员
呆萌很20 分钟前
Sigmoid 与 Tanh 激活函数(S 型饱和激活函数)
人工智能·深度学习·机器学习
leeyi21 分钟前
MultiAgent Host 源码 + ADK prebuilt 三种预制模式(第92篇-E78)
人工智能·aigc·agent
前沿在线21 分钟前
WRC2026丨当机器开始理解人的意图,人机交互走向更多场景
人工智能·ai·大模型
动物园猫27 分钟前
红外无人机目标检测数据集:4,500+张图像 | 目标检测
人工智能·目标检测·无人机
达子66627 分钟前
AI训练师图解_6.1_让AI理解人类语言_自然语言处理
人工智能·自然语言处理
Linguwen30 分钟前
中山GEO分享会回顾文
人工智能·chatgpt
武子康32 分钟前
多 Agent 不是多开几个终端:Pi 的 Sub-agent 取舍
人工智能·llm·agent
俊哥V39 分钟前
每日 AI 研究简报 · 2026-08-22
人工智能·ai
龙虾PRO43 分钟前
数据中台 + AI 落地:2026 五大趋势与零售出海完整实操案例
人工智能·零售