{"id":20461347,"url":"https://github.com/antvis/vis-predict-engine","last_synced_at":"2025-04-13T06:16:11.099Z","repository":{"id":50232097,"uuid":"312458633","full_name":"antvis/vis-predict-engine","owner":"antvis","description":"可视化预测引擎，目前只用于预测图可视化布局.布局预测的模型由本引擎内置，支持force/radial/concentric/circular的四布局分类","archived":false,"fork":false,"pushed_at":"2021-06-01T07:43:23.000Z","size":19,"stargazers_count":15,"open_issues_count":1,"forks_count":3,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-13T06:15:51.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antvis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-13T03:03:45.000Z","updated_at":"2025-04-02T00:19:37.000Z","dependencies_parsed_at":"2022-08-17T16:05:59.907Z","dependency_job_id":null,"html_url":"https://github.com/antvis/vis-predict-engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fvis-predict-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fvis-predict-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fvis-predict-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fvis-predict-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antvis","download_url":"https://codeload.github.com/antvis/vis-predict-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670438,"owners_count":21142905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T12:24:51.661Z","updated_at":"2025-04-13T06:16:11.076Z","avatar_url":"https://github.com/antvis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @antv/vis-predict-engine 可视化预测引擎\n\n## 图布局预测\n目前布局预测的模型由本引擎内置，支持force/radial/concentric/circular的四布局分类，后续将支持更多布局分类。\n\n### 使用方法\n```\nimport { GraphLayoutPredict } from '@antv/vis-predict-engine';\nconst { predictLayout, confidence } = await GraphLayoutPredict.predict(data, expectLayout, showLog);\n```\n**入参**：\n- **data**: 图数据（格式见使用示例），必传; \n- **expectLayout**: 期望布局('force' | 'radial' | 'concentric' | 'circular' )，如无期望布局可传undefined; \n- **showLog**: 是否需要是输出日志（布尔）, 传false或不传则不输出日志；\n**返回**：\n- **predictLayout**: 预测布局, string; \n- **confidence**: 置信度，number。\n\n\n### 使用示例\n```\nimport G6 from \"@antv/g6\";\nimport { GraphLayoutPredict } from \"@antv/vis-predict-engine\";\n\nconst data = {\n  nodes: [\n    {\n      id: \"node-0\",\n      label: \"0\"\n    },\n    {\n      id: \"node-1\",\n      label: \"1\"\n    },\n    {\n      id: \"node-2\",\n      label: \"2\"\n    },\n    {\n      id: \"node-3\",\n      label: \"3\"\n    },\n    {\n      id: \"node-4\",\n      label: \"4\"\n    },\n    {\n      id: \"node-5\",\n      label: \"5\"\n    },\n    {\n      id: \"node-6\",\n      label: \"6\"\n    },\n    {\n      id: \"node-7\",\n      label: \"7\"\n    },\n    {\n      id: \"node-8\",\n      label: \"8\"\n    },\n    {\n      id: \"node-9\",\n      label: \"9\"\n    }\n  ],\n  edges: [\n    {\n      id: \"edge-0\",\n      source: \"node-0\",\n      target: \"node-1\"\n    },\n    {\n      id: \"edge-1\",\n      source: \"node-0\",\n      target: \"node-2\"\n    },\n    {\n      id: \"edge-2\",\n      source: \"node-0\",\n      target: \"node-3\"\n    },\n    {\n      id: \"edge-4\",\n      source: \"node-0\",\n      target: \"node-4\"\n    },\n    {\n      id: \"edge-5\",\n      source: \"node-0\",\n      target: \"node-5\"\n    },\n    {\n      id: \"edge-6\",\n      source: \"node-1\",\n      target: \"node-6\"\n    },\n    {\n      id: \"edge-7\",\n      source: \"node-6\",\n      target: \"node-7\"\n    },\n    {\n      id: \"edge-8\",\n      source: \"node-5\",\n      target: \"node-7\"\n    },\n    {\n      id: \"edge-9\",\n      source: \"node-1\",\n      target: \"node-4\"\n    },\n    {\n      id: \"edge-10\",\n      source: \"node-4\",\n      target: \"node-5\"\n    },\n    {\n      id: \"edge-11\",\n      source: \"node-3\",\n      target: \"node-7\"\n    },\n    {\n      id: \"edge-12\",\n      source: \"node-2\",\n      target: \"node-5\"\n    },\n    {\n      id: \"edge-13\",\n      source: \"node-2\",\n      target: \"node-1\"\n    }\n  ]\n};\n\nasync function layoutPredict() {\n  return await GraphLayoutPredict.predict(data);\n}\n\n(async function () {\n  // predictLayout 表示预测的布局：force | radial | concentric | circular\n  // confidence 表示预测的可信度\n  const { predictLayout, confidence } = await layoutPredict();\n  const container = document.getElementById(\"root\");\n  const graph = new G6.Graph({\n    container,\n    width: container.scrollWidth,\n    height: container.scrollHeight || 500,\n    layout: {\n      type: predictLayout,\n      nodeSize: 50,\n      preventOverlap: true\n    },\n    modes: {\n      default: [\"drag-canvas\", \"zoom-canvas\", \"drag-node\"]\n    }\n  });\n\n  graph.data(data);\n  graph.render();\n  graph.on(\"afterlayout\", () =\u003e {\n    graph.fitView();\n  });\n\n  if (typeof window !== \"undefined\") {\n    window.onresize = () =\u003e {\n      if (!graph || graph.get(\"destroyed\")) return;\n      if (!container || !container.scrollWidth || !container.scrollHeight)\n        return;\n      graph.changeSize(container.scrollWidth, container.scrollHeight);\n    };\n  }\n})();\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fvis-predict-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantvis%2Fvis-predict-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fvis-predict-engine/lists"}