Skip to content

feat: viewer and admin console built on hypergraph-viz - #13

Open
yuxizhe wants to merge 11 commits into
iMoonLab:mainfrom
yuxizhe:feat/hypergraph-viz
Open

yuxizhe wants to merge 11 commits into
iMoonLab:mainfrom
yuxizhe:feat/hypergraph-viz

Conversation

@yuxizhe

@yuxizhe yuxizhe commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

image

The viewer (hg.draw(), /viewer) and the admin console (hg.admin()) now come from hypergraph-viz 0.2.0, the hypergraph UI library shared with HypergraphViewer and the Hyper-RAG web UI. Both pages are now a few dozen lines that mount a component from a pinned unpkg build, instead of ~2,000 lines of React compiled in the browser by Babel and Tailwind.

hg.draw()   # viewer
hg.admin()  # admin console, with the viewer at /viewer

No new Python dependencies; the Python API is unchanged except for an optional labels argument to admin().

Viewer

  • Hypergraph layout: members of a hyperedge are placed together and non-members are pushed out of its contour. Contours are bubble sets drawn around nodes only, and labels avoid overlapping.
  • Left panel: database counts and the vertex list with search, sorting by degree or name, and pagination; any vertex can be the center. ?vertex=<id> sets the initial center (used by the admin console's links).
  • Canvas: hover a vertex, line or contour to highlight it and show its attributes in a card next to the pointer; click a hyperedge to highlight its members and fade the rest. Toolbar with zoom, fit and full screen; high-degree hubs are faded out of the layout by default.
  • Right panel: subgraph statistics (degree and size distributions, entity types, hubs), vertex and hyperedge tables, render settings (layout, colors, labels) and the detail view.
  • Chinese / English UI, sharing the language choice with the admin console.

Admin console

Same features as before (overview, vertex and hyperedge CRUD with a JSON editor, HIF import / export, explicit save), now from hypergraph-viz/admin, plus:

  • Relation graph in the vertex detail (the vertex's subgraph from /api/graph).
  • Hyperedge types in the overview (count by the hyperedge type attribute) replace the top-vertices list; clicking a type opens the hyperedge list filtered by it (/api/admin/edges?edge_type=).
  • Display labels: hg.admin(labels=...) (a dict or a JSON path), or <name>.labels.json next to the .hgdb file, shaped {lang: {entity_type | edge_type | key: {value: label}}}. Labels only change what is shown; filters and the API keep the raw values.

Other changes

  • /api/vertices: sorting by degree or ID no longer forces vertices with degree > 50 to the end of the list; ties are broken by ID so pages are stable.
  • draw.py no longer serves static files; the custom g6.min.js is replaced by @antv/g6@5.0.49 from unpkg.
  • /api/admin/stats returns edge_types instead of top_vertices.

Tests

34 tests pass. New tests cover hyperedge type stats and filtering, the label file (found, malformed, passed explicitly), vertex sorting with a degree-60 hub, and that both pages load the pinned hypergraph-viz build.

Checked in the browser on the 三国演义 database (4,359 vertices, 3,137 hyperedges), a copy of the Hyper-RAG neurology database and a database with int IDs: browsing and sorting in the viewer, full screen, switching language; in the admin console creating, editing and deleting vertices and hyperedges, saving, exporting HIF and the relation graph, with no page errors.

🤖 Generated with Claude Code

yuxizhe and others added 11 commits October 16, 2026 16:27
…type

Hyper-RAG 原版抽取的图等超边没有 type 字段,keywords 是超边仅有的说明;
有 type 时(如 finhg 导出的图)仍不显示 keywords。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 点击超边轮廓或连线:该超边加深加粗,成员实体描边、标签加粗,其余实体、连线、
  超边轮廓变淡;侧边栏固定显示该超边,不随悬停变化
- 再点同一条或点空白处取消;切换数据时清除
- 节点 / 连线基础样式显式写出 opacity、lineWidth、labelFontWeight,
  否则 G6 移除状态后保留状态样式

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bels

- 概览页用“超边类型”(按超边 type 计数)替换“度数最高的实体”;点击类型跳到
  按类型筛选的超边列表;超边列表新增类型筛选(/api/admin/edges?edge_type=)
- 显示名映射:hg.admin(labels=...) 传入,或自动读取 .hgdb 旁的 <name>.labels.json,
  格式 {lang: {entity_type|edge_type|key: {值: 显示名}}};经 /api/admin/info 下发,
  概览卡片、类型下拉、实体列表按当前语言显示,筛选与接口仍用原始值
- 测试:超边类型统计、按类型筛选、映射文件读取 / 格式错误 / 显式传入

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om g6.min.js

- G6 改从 unpkg 加载固定版本,不再依赖 http://hub.dappwind.com 上的定制构建
- 内联 HoverBubbleSets 插件(与 HypergraphViewer、Hyper-RAG web-ui 同一实现),
  在原版 BubbleSets 上补齐:轮廓转发悬停 / 点击事件、布局中隐藏、首次渲染前销毁
  不抛异常、配置更新后立即应用样式;注册为 'hover-bubble-sets'
- 换数据时 destroy 旧图(clear 后力导布局仍在迭代会报 Node not found),
  首次渲染前销毁抛异常时补销毁画布

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sets without label overlap

- 新增 templates/hypergraph_layout.js(由 G6 仓库 hypergraph/build-hypergraph-layout.mjs 生成的全局版),
  draw.py 以静态路由 /hypergraph_layout.js 提供;脚本未加载时退回 force 布局
- 以选中实体为中心,节点间距 50、标签防重叠;bubble-sets edgeR0 30 / edgeR1 50
- 关闭动画:animate 不是 G6 v5 选项,改为 animation: false

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hypergraph_viewer.html 改用 window.HypergraphViz(createHypergraphView 等),去掉内联的悬停轮廓、数据转换和选中高亮
- 用 hypergraph-viz.global.js(0.1.0)替换 hypergraph_layout.js,draw 服务改为提供 /hypergraph-viz.global.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sorted list

旧查看器为了默认中心避开枢纽实体,把度数大于 50 的实体固定排在列表末尾,导致按度数降序时最大的实体在最后、
按 ID 倒序时两组整体颠倒。现在严格按所选顺序,度数相同时按 ID,分页稳定。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…console

- hypergraph_viewer.html:mountExplorer(左栏实体列表、画布、右栏子图统计与渲染设置),数据源接 /api/database/info、
  /api/vertices、/api/graph;?vertex= 指定默认中心,语言与管理后台共用 hgdb-admin-lang
- admin.html:mountAdmin + createHttpAdminApi('/api/admin'),实体详情中多了关系图(/api/graph);
  不再在浏览器里用 Babel 和 Tailwind 编译
- 两个页面从 unpkg 加载固定版本的 hypergraph-viz,去掉仓库里的 hypergraph-viz.global.js 与 draw 服务的静态文件路由;
  测试改为检查两个页面引用的 CDN 地址

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant