A knowledge graph relationship constraint layout method and system, and a storage medium

By constructing geometric constraint regions corresponding to business levels and iteratively updating the resultant force model, the problems of hierarchical structure clarity and layout stability in multi-level knowledge graphs are solved, and stable knowledge graph display is achieved.

CN123048794APending Publication Date: 2026-11-06THREE GORGES HI TECH INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611337554.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-31
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing knowledge graph layout methods cannot simultaneously guarantee the clarity of the hierarchical structure and the stability of the layout results in multi-level scenarios. Traditional force-oriented algorithms ignore the business level attributes of nodes, resulting in hierarchical confusion. Browser-side calculations cause node position drift and jitter, making it difficult to take into account the positions of multiple parent nodes.

Method used

By constructing geometric constraint regions corresponding to business-level attributes, iterative updates are performed using a resultant force model to output static coordinate data. Combining edge constraints and region constraints, the system ensures that nodes are stably distributed within a specified spatial region, reducing browser-side computation.

Benefits of technology

It achieves a clear hierarchical structure and stable layout for multi-level knowledge graphs, eliminates node drift and jitter, and improves user interaction experience and data interpretation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123048794A_ABST
    Figure CN123048794A_ABST
Patent Text Reader

Abstract

The application discloses a knowledge graph relationship constraint layout method and system and a storage medium. The method comprises the following steps: acquiring a node set, an edge set and a canvas size with a business hierarchical attribute; constructing a geometric constraint area corresponding to the business hierarchical attribute, and initializing the nodes into the area; calculating the resultant force suffered by the nodes by using a resultant force model and iteratively updating the coordinates, and outputting static coordinate data; the resultant force comprises an edge constraint force and an area constraint force; the application guarantees a clear hierarchical structure by using the geometric constraint area, eliminates front-end jitter by using back-end static calculation, solves the problems of hierarchical confusion and unstable results in multi-level knowledge graph layout, and improves the visual interactive experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, specifically to a relation constraint layout method, system, and storage medium for a knowledge graph. Background Technology

[0002] With the widespread application of knowledge graph technology, a key issue has become how to present complex graph data to users in an intuitive and clear way. Currently, the visualization layout of knowledge graphs mainly relies on force-directed layout algorithms, such as the spring-charge model based on physical models.

[0003] In related technologies, browser-side JavaScript libraries are typically used for real-time force-directed calculations. The algorithm simulates the repulsive forces between nodes and the attractive forces between edges to automatically distribute nodes on the canvas to achieve the lowest energy state.

[0004] However, existing technologies have the following technical problems when processing knowledge graphs with clear business levels (such as industry chains, links, tags, etc.): (1) Traditional force-oriented algorithms only consider topological connections and ignore the business level attributes of nodes, resulting in a mixed distribution of nodes at different levels. Core nodes and edge nodes cannot be effectively distinguished in space, resulting in loss of hierarchical semantics and insufficient clarity of hierarchical structure.

[0005] (2) Existing solutions rely on continuous computation on the browser side. Due to fluctuations in client performance, node positions are prone to drifting or jittering and are difficult to converge to an absolutely stable state, affecting the user interaction experience.

[0006] (3) For child nodes with multiple parent nodes, existing technologies often cannot take into account the position of all related parent nodes, resulting in excessively long related edges or distorted layout. Summary of the Invention

[0007] This application provides a relational constraint layout method, system, and storage medium for knowledge graphs, which can solve the technical problem that existing knowledge graph layout methods cannot simultaneously guarantee the clarity of the hierarchical structure and the stability of the layout results in multi-level scenarios.

[0008] In a first aspect, embodiments of this application provide a relation constraint layout method for a knowledge graph, comprising: Obtain the node set and edge set of the knowledge graph, as well as the canvas size; wherein, the nodes in the node set have business level attributes, and the edge set is used to represent the connection relationship between the nodes; Based on the canvas size and the business level attribute, construct multiple geometric constraint regions that correspond one-to-one with the business level attribute; initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes; The resultant force on a node is calculated using a resultant force model, and the initial coordinates of the node are iteratively updated based on the resultant force. When the iteration meets the convergence condition, the latest coordinates of the node are output and used as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set and the region constraint force used to confine the node within the geometric constraint region.

[0009] Preferably, the business hierarchy attributes of the node include level one, level two, and level three; Based on the canvas size and the business hierarchy attribute, construct multiple geometric constraint regions that correspond one-to-one with the business hierarchy attribute, including: Using the canvas center point determined by the canvas size as a common center, construct three concentric elliptical rings; The inner elliptical ring is used to constrain nodes with a business level attribute of level one; the middle elliptical ring is used to constrain nodes with a business level attribute of level two; and the outer elliptical ring is used to constrain nodes with a business level attribute of level three. The radii of the middle and inner elliptical rings are obtained by scaling the radius of the outer elliptical ring.

[0010] Preferably, nodes with a business level attribute of level one are sorted by stable identifiers and evenly distributed along the inner elliptical ring. The parent node is determined based on the connection relationship between nodes with a business hierarchy attribute of level two and nodes with a business hierarchy attribute of level one. Secondary nodes located under the same first-level parent node are initialized to the same sector within the elliptical ring of the middle layer. The central angle of the sector is determined by the position of the corresponding first-level parent node on the inner elliptical ring. When the number of secondary nodes in the same sector exceeds the preset single ring capacity, a supplementary ring is generated within the radial range of the elliptical ring of the middle layer to arrange the secondary nodes.

[0011] Preferably, initializing the nodes in the node set to the corresponding geometric constraint region further includes: Find the second-level parent node that is associated with the third-level node; If there are multiple second-level parent nodes, obtain the coordinates of all second-level parent nodes relative to the center point of the canvas, calculate the average direction angle, use the average direction angle as the sector center angle of the third-level node, and initialize the third-level node to the corresponding sector within the outer elliptical ring. If there is no second-level parent node, the third-level node is assigned to the pre-defined bottom sector within the outer elliptical ring.

[0012] Preferably, calculating the edge constraint force based on the edge set includes: For each edge in the edge set, set the corresponding target distance and weight coefficient for the business level attributes of the two nodes connected by each edge. The edge constraint force is calculated based on the target distance and weighting coefficient; Specifically, the target distance between the edge between the second-level node and the third-level node is less than the target distance between the edge between the first-level node and the second-level node, and the weight coefficient of the edge between the second-level node and the third-level node is greater than the weight coefficient of the edge between the first-level node and the second-level node.

[0013] Preferably, the resultant force on the node is calculated using a resultant force model, specifically including: Obtain the node spacing between two nodes, and determine whether a node exceeds the boundary of its geometric constraint region; When the distance between the nodes is less than the safety threshold, calculate the collision avoidance force between the two nodes; When it exceeds the boundary of its geometric constraint region, calculate the region constraint force of its geometric constraint region; The collision avoidance force is used as a repulsive force, the region constraint force is used as a restoring force pointing towards the center of the geometric constraint region, and the resultant force is obtained by combining the edge constraint force.

[0014] Preferably, iteratively updating the initial coordinates of the node based on the resultant force includes: During the iteration process, set the temperature coefficient and the maximum displacement per cycle that decay with the iteration progress; The displacement vector of the node is calculated based on the resultant force, and the magnitude of the displacement vector is limited by the temperature coefficient and the maximum displacement of a single wheel. The initial coordinates of the node are updated based on the constrained displacement vector.

[0015] Preferably, after outputting the latest coordinates of the nodes and using them as static coordinate data, the method further includes: The static coordinate data is sent to the front-end rendering engine; The front-end rendering engine directly draws nodes and edges based on the static coordinate data, disabling continuous force-guided layout calculations on the browser side.

[0016] Secondly, a relation constraint layout system for knowledge graphs is provided, which includes: The first module is used to obtain the node set and edge set of the knowledge graph, as well as the canvas size; wherein, the nodes in the node set have business level attributes, and the edge set is used to represent the connection relationship between the nodes; The second module is used to construct multiple geometric constraint regions that correspond one-to-one with the business level attributes based on the canvas size and the business level attributes; and to initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes. The third module is used to calculate the resultant force on the node using the resultant force model, and to iteratively update the initial coordinates of the node according to the resultant force. When the iteration meets the convergence condition, the latest coordinates of the node are output as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set, and the region constraint force used to confine the node within the geometric constraint region.

[0017] Thirdly, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements a relation constraint layout method for a knowledge graph.

[0018] The beneficial effects of the technical solutions provided in this application include: By constructing geometric constraint regions that correspond one-to-one with business hierarchy attributes, nodes at different levels are forced to reside in different spatial regions, effectively solving the problems of mixed hierarchical structures and unclear semantics in multi-level knowledge graphs. Simultaneously, a combined force model including edge and region constraints is used for iterative optimization on the backend, outputting static coordinate data. This eliminates the need for continuous force-directed calculations on the frontend, not only eliminating node drift and jitter caused by browser performance fluctuations and ensuring the stability of the layout result, but also significantly reducing the rendering pressure on the frontend. Furthermore, through the synergistic effect of region and edge constraints, the relative positions of nodes are optimized while satisfying hierarchical constraints, avoiding layout rigidity. Ultimately, a stable, non-overlapping, and rapidly converging knowledge graph layout effect is achieved while maintaining clear business hierarchy semantics, significantly improving the user's visual interaction experience and data interpretation efficiency. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the node flow of the relation constraint layout method for the knowledge graph in this application; Figure 2 This is a schematic diagram of the multi-level elliptical ring layout of the relation constraint layout method for the knowledge graph of this application. Figure 3 This is a detailed flowchart illustrating the relational constraint layout method for the knowledge graph in this application. Detailed Implementation

[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0022] Firstly, a relation constraint layout method for knowledge graphs is provided, which includes: Step 100: Obtain the node set and edge set of the knowledge graph, as well as the canvas size; where the nodes in the node set have business level attributes, and the edge set is used to represent the connection relationship between nodes; Step 200: Based on the canvas size and business level attributes, construct multiple geometric constraint regions that correspond one-to-one with the business level attributes; initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes; Step 300: Calculate the resultant force on the node using the resultant force model, and iteratively update the initial coordinates of the node according to the resultant force. When the iteration meets the convergence condition, output the latest coordinates of the node and use them as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set, and the region constraint force used to confine the node within the geometric constraint region.

[0023] The knowledge graph relation constraint layout method provided in this embodiment can be executed by a server or a terminal device with computing capabilities. The technical problem it aims to solve is that existing knowledge graph layout methods, in multi-level scenarios, cannot simultaneously guarantee the clarity of the hierarchical structure and the stability of the layout result. The specific principle behind solving this technical problem is explained below: By constructing multiple geometric constraint regions corresponding one-to-one with business hierarchy attributes based on canvas size and business hierarchy attributes, and initializing nodes in the node set to their corresponding geometric constraint regions, the semantic clarity of the business hierarchy is guaranteed by physical space isolation, avoiding hierarchical confusion. By calculating the resultant force on the node using the resultant force model and iteratively updating it, and outputting the latest coordinates of the node as static coordinate data on the backend, the time-consuming optimization calculation is moved to the backend, and the frontend only renders static results, eliminating position drift and jitter caused by continuous calculation on the browser side. By including both edge constraint forces calculated based on edge sets and region constraint forces used to restrict nodes to geometric constraint regions in the resultant force model, the relative positions of nodes can be optimized according to connection relationships while satisfying hierarchical constraints, avoiding layout rigidity caused by excessive constraints. In summary, through the synergistic effect of steps 100-300, the technical problem that existing knowledge graph layout methods cannot simultaneously guarantee the clarity of the hierarchical structure and the stability of the layout results in multi-level scenarios is solved.

[0024] The technical solution of this application will be described in detail below with specific steps.

[0025] Step 100: Obtain the node set and edge set of the knowledge graph, as well as the canvas size.

[0026] Specifically, all nodes in the knowledge graph are acquired, along with multiple edges representing the connections between nodes, forming an edge set. Nodes are then categorized into first-level nodes (e.g., CHAIN / industry chain), second-level nodes (e.g., NODE / link), and third-level nodes (e.g., TAG / tag). Nodes in the node set possess business-level attributes, and the edge set represents the connections between nodes. In this implementation, "edge data" includes not only connection relationships but also mechanical metadata for differentiated layout.

[0027] Existing technologies often lack a structured definition of node business attributes before layout, causing layout algorithms to fail to identify the importance hierarchy of nodes and treat all nodes equally. This embodiment provides basic data support for subsequent hierarchical constraint layout by clearly defining the business hierarchy attributes of nodes and the connection relationships of edges, ensuring that the layout algorithm can perceive business semantics and providing a basis for the construction of hierarchical constraint regions.

[0028] Algorithm Implementation Example 1: Data Structure and Layout Entry Point TypeScript type NodeType = 'CHAIN' | 'NODE' | 'TAG'; interface GraphNode { id: string; code: string; type: NodeType; label: string} interface GraphEdge { source: string; target: string} function layoutKnowledgeGraph(nodes: GraphNode[], edges: GraphEdge[], size: { width: number; height: number}) { const nodeMap = new Map(nodes.map(node ​​=>[node.id, node])); / / Construct an adjacency list and its mapping to the parent node chain const adjacencyMap = buildAdjacencyMap(nodes, edges); const parentMap = buildNodeChainParentMap(nodes, adjacencyMap,nodeMap); / / Get initial position and ring constraint const initial = getInitialPositionMap(nodes, size, adjacencyMap,nodeMap); / / Perform optimization and return results return optimizePositionMap(initial.positionMap, edges, { nodes, nodeMap, adjacencyMap, parentMap, ringConstraints: initial.ringConstraints, size }); } Step 200: Based on the canvas size and business level attributes, construct multiple geometric constraint regions that correspond one-to-one with the business level attributes; initialize the nodes in the node set to their corresponding geometric constraint regions to obtain the initial coordinates of the nodes. Specifically, this includes: Step 2001: Construct the geometrically constrained region Determine the canvas center point (centerX, centerY) based on the canvas width and height. Calculate the radii of the inner, middle, and outer ellipses. The outer radius is dynamically calculated based on the canvas size, while the middle and inner radii are scaled proportionally based on the outer radius. Constrain first-level nodes to the inner elliptical ring, second-level nodes to the middle elliptical ring, and tertiary nodes to the outer elliptical ring. The canvas center point determined by the canvas size serves as a common center, constructing three concentric elliptical rings. The inner elliptical ring constrains nodes with a first-level business hierarchy attribute; the middle elliptical ring constrains nodes with a second-level business hierarchy attribute; and the outer elliptical ring constrains nodes with a third-level business hierarchy attribute. The radii of the middle and inner elliptical rings are obtained by scaling the radius of the outer elliptical ring proportionally. If the rings have width, it should be clearly specified whether the scaling is based on the inner boundary, the outer boundary, or the centerline.

[0029] In existing technologies, multi-level nodes are easily mixed and distributed, resulting in unclear hierarchical semantics and making it difficult for users to quickly identify core and edge nodes. This embodiment constructs geometrically constrained regions (such as concentric elliptical rings) that correspond one-to-one with business hierarchical attributes, forcing nodes of different levels to be located in different spatial regions. This ensures the clarity of the hierarchical structure from a physical layout perspective, and the proportional scaling of the radius can adapt to different canvas sizes, avoiding regions that are too large or too small.

[0030] Algorithm Implementation Example 2: Initialization of Layered Elliptical Rings TypeScript const centerX = width / 2; const centerY = height / 2; / / Outer radius (third-level node region) const outerRadiusX = Math.max(220, width / 2 - 88); const outerRadiusY = Math.max(220, height / 2 - 68); / / Mid-level radius (secondary node region, scale 0.68) const middleRadiusX = outerRadiusX * 0.68; const middleRadiusY = outerRadiusY * 0.68; / / Inner radius (first-level node region, scale 0.24) const innerRadiusX = Math.min(128, outerRadiusX * 0.24); const innerRadiusY = Math.min(96, outerRadiusY * 0.24); / / Each node records both minRatio and maxRatio for subsequent use in ring band constraints. Step 2002, Node Initialization Nodes with a business level attribute of level 1 are sorted by stable identifier and evenly distributed along the inner elliptical ring, or a single level 1 node is placed near the center point of the canvas (when the level 1 node is located at the center point of the canvas, the level 2 nodes are evenly distributed in the middle elliptical ring).

[0031] The primary parent node is determined based on the connection relationship between nodes with a business hierarchy attribute of level two and nodes with a business hierarchy attribute of level one. Level two nodes located under the same level one parent node are initialized to the same sector within the elliptical ring of the middle layer. The central angle of the sector is determined by the position of the corresponding level one parent node on the inner elliptical ring. When the number of level two nodes in the same sector exceeds the preset single ring capacity, a supplementary ring is generated within the radial range of the elliptical ring of the middle layer to arrange the level two nodes.

[0032] Traditional initialization methods often result in overly scattered or crowded child nodes under the same parent node, and overlap can easily occur when the number of nodes is large, affecting label readability. This embodiment achieves a balanced distribution of secondary nodes through sector incorporation and supplementary ring mechanisms. In particular, when the number of nodes exceeds the capacity, supplementary rings are generated inward instead of reducing the node size, ensuring the readability of node labels, while clarifying parent-child relationships and reducing edge intersections.

[0033] Furthermore, step 2002 also includes: finding the second-level parent node associated with the third-level node; If there are multiple second-level parent nodes, obtain the coordinates of all second-level parent nodes relative to the center point of the canvas, calculate the average direction angle, use the average direction angle as the sector center angle of the third-level node, and initialize the third-level node to the corresponding sector within the outer elliptical ring. If there is no second-level parent node, the third-level node will be assigned to the pre-defined bottom sector within the outer elliptical ring.

[0034] For third-level nodes with multiple parent nodes, existing technologies often place them arbitrarily or based on only a single parent node, resulting in excessively long associated edges or unreasonable layouts, failing to consider all relationships. This embodiment calculates the average orientation angle of multiple parent nodes, taking into account the positions of multiple associated parent nodes, effectively reducing the problem of excessively long edges, and making multiple parent nodes visually closer to the center of all their parent nodes; the setting of the catch-all sector avoids the loss of nodes without parent nodes, ensuring the integrity of the graph.

[0035] Algorithm Implementation Example 3: Grouping of Multiple Parent Three-Level Nodes TypeScript function getAverageParentAngle(parents, positionMap, centerX,centerY) { / / Get the coordinates of all parent nodes const points = parents.map(parent =>positionMap.get(parent.id)).filter(Boolean); / / Calculate average coordinates const averageX = points.reduce((sum, point) =>sum + point.x, 0) / points.length; const averageY = points.reduce((sum, point) =>sum + point.y, 0) / points.length; / / Returns the angle relative to the center of the canvas return Math.atan2(averageY - centerY, averageX - centerX); } / / When a third-level node is associated with multiple second-level parent nodes, the average direction of the multiple parent nodes is used as the sector center. Step 300: Calculate the resultant force on the node using the resultant force model, and iteratively update the node's initial coordinates based on the resultant force. When the iteration meets the convergence condition, output the latest coordinates of the node as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set, and the region constraint force used to confine the node within the geometric constraint region. Specifically, it includes the following steps: Step 3001: Calculation of Differentiated Edge Constraint Force For each edge in the edge set, set the corresponding target distance and weight coefficient for the business level attributes of the two nodes connected by each edge. Specifically, the target distance between the edge between a second-level node and a third-level node is less than the target distance between the edge between a first-level node and a second-level node, and the weight coefficient of the edge between a second-level node and a third-level node is greater than the weight coefficient of the edge between a first-level node and a second-level node.

[0036] Existing technologies typically apply uniform mechanical parameters to all edges, resulting in insufficient prominence of the main reading path (such as the transition from level two to level three) or instability of the core framework (from level one to level two), leading to unclear visual focus. This embodiment differentiates the target distance and weight coefficients, making the relationship between level two and level three (the main reading path) more tightly integrated, while maintaining an appropriate distance between level one and level two relationships. This optimizes visual focus and structural stability, making it easier for users to pay attention to detail labels.

[0037] Algorithm Implementation Example 4: Differentiated Edge Weights and Target Edge Length TypeScript function getEdgeLayoutMeta(sourceNode, targetNode, parentMap) { if (isChainNodeEdge(sourceNode, targetNode)) return { targetDistance: 220, weight: 0.07}; / / Level 1 - Level 2 if (isNodeTagEdge(sourceNode, targetNode)) return { targetDistance: 170, weight: 0.12}; / / Level 2 - Level 3 (high weight) if (isNodeNodeEdge(sourceNode, targetNode)) { const sameParent = parentMap.get(sourceNode.id) === parentMap.get(targetNode.id); / / Second-level nodes with the same parent have strong attraction, while those across parent nodes have weak attraction. return { targetDistance: 185, weight: sameParent ? 0.10 : 0.055}; } return { targetDistance: 260, weight: 0}; / / Bottom edge } Step 3002, Calculation of Resultant Force Model Obtain the node distance between two nodes and determine whether a node exceeds the boundary of its geometric constraint region. When the node distance is less than the safety threshold, calculate the collision avoidance force between the two nodes; when it exceeds the boundary of its geometric constraint region, calculate the region constraint force of its geometric constraint region. Treat the collision avoidance force as a repulsive force and the region constraint force as a restoring force pointing towards the center of the geometric constraint region, and sum them with the edge constraint force to obtain the resultant force.

[0038] Relying solely on edge constraints can easily lead to node overlap or nodes jumping out of their respective hierarchical regions, violating hierarchical constraints and causing layout chaos. In this embodiment, collision avoidance forces prevent node overlap, while region constraints ensure that nodes always remain within the specified hierarchical ring. The combination of these two with edge constraints achieves a layout that is both aesthetically pleasing and conforms to business constraints, ensuring the rigidity of hierarchical constraints.

[0039] Step 3003: Iterative Update and Convergence Control During the iteration process, a temperature coefficient and a maximum single-wheel displacement that decay with the iteration progress are set. The displacement vector of the node is calculated based on the resultant force, and the magnitude of the displacement vector is limited by the temperature coefficient and the maximum single-wheel displacement.

[0040] Traditional force-directed algorithms are prone to getting stuck in local optima or generating infinite oscillations, leading to unstable layout convergence, wasted computational resources, and unusable results. This embodiment uses temperature coefficient and maximum displacement decay control to allow larger displacements in the early stages to handle long-distance relationships and significant overlaps, while using smaller displacements in the later stages to ensure layout stability. This avoids infinite oscillations of nodes due to parent-child interactions and ensures rapid convergence to a stable state.

[0041] Algorithm Implementation Example 5: Fixed-Round Constraint Optimization and Convergence Control TypeScript for (let iteration = 0; iteration<800; iteration += 1) { const progress = iteration / 799; / / Temperature coefficient decay: fast in the early stage, slow in the later stage const temperature = 1 - progress * 0.72; / / Maximum displacement decay: decreased from 8 to 1.2 const maxStep = 8 - (8 - 1.2) * progress; const forceMap = createEmptyForceMap(nodes); / / Apply three forces (corresponding to step seven) applyEdgeForces(edges, positionMap, forceMap, nodeMap, parentMap,temperature); applyCollisionForces(nodes, positionMap, forceMap, temperature); applyRingForces(nodes, positionMap, forceMap, ringConstraints,temperature); / / Update position (corresponding to step size control in step eight) applyForcesToPositions(nodes, positionMap, forceMap, size, maxStep); } In some preferred embodiments, the knowledge graph relation constraint layout method further includes steps 400 and 500; Step 400, after outputting the latest coordinates of the nodes and using them as static coordinate data, also includes: sending the static coordinate data to the front-end rendering engine; the front-end rendering engine directly draws the nodes and edges based on the static coordinate data, and disables the browser's continuous force-guided layout calculation.

[0042] Existing technologies continuously perform force-directed calculations on the browser side, which not only consumes client resources but may also cause node positions to drift or jitter, affecting the user experience, especially in large-scale graph scenarios. This embodiment calculates and outputs static coordinates on the backend, with the frontend only responsible for rendering. This completely eliminates the instability caused by dynamic calculations on the frontend, achieving stability in graph display, reducing the computational burden on the frontend, and improving rendering performance.

[0043] Step 500: Output the static layout result.

[0044] After the iteration is complete, the coordinates of each node are written into the graph rendering data, and the node size, color, stroke, maximum label width, label line breaks, and edge style are set according to the node type.

[0045] In summary, this application effectively solves the readability and stability problems in existing multi-level knowledge graph displays by using a combination of "hierarchical initial layout + multi-parent node grouping + differentiated edge constraints + collision avoidance + ring constraints + static coordinate output". The specific technical effects are as follows: This invention employs elliptical ring constraints to ensure that first-, second-, and third-level nodes are situated in relatively stable spatial hierarchies. Compared to the hierarchical confusion caused by general force-oriented layouts, this solution allows users to directly understand hierarchical relationships through node positions. During layout iteration, nodes are constrained within specific ring regions, preventing hierarchical jumps and significantly improving the clarity of the hierarchical structure.

[0046] Second-level nodes are arranged according to the sectors of their first-level parent nodes, and third-level nodes are arranged according to the sectors of their second-level parent nodes, ensuring the spatial proximity of parent and child nodes. Especially for multi-parent third-level nodes, this embodiment uses the average direction of multiple parent nodes to determine the initial sector, which can take into account multiple associated parent nodes, reduce the problem of multiple relationship edges being too long at the same time, and thus optimize the visual connection relationship.

[0047] To address the issue of excessive nodes, this embodiment employs a multi-ring arrangement within sectors and calculates the collision radius based on node dimensions, applying collision avoidance forces only when nodes overlap. This local avoidance mechanism prevents node overlap and avoids excessive expansion of the graph by global repulsion forces, effectively improving space utilization. This embodiment uses different target distances and weights for different types of edges, prioritizing primary reading paths such as those from level one to level two, level two to level three, and level two to level two in layout optimization, while auxiliary edges do not disrupt the main hierarchical structure. This differentiated constraint reduces edge intersections and visual interference, improving relational readability.

[0048] The iterative process employs a temperature- and maximum step-size decreasing mechanism, allowing the layout to quickly approach a reasonable structure before gradually converging to a stable state. Finally, static coordinates are output to the rendering engine to prevent node drift after page rendering. This mechanism improves stability in scenarios involving clicks, hovering, highlighting, screenshots, and presentations, ensuring smooth user interaction.

[0049] Secondly, this application also provides a relation constraint layout system for knowledge graphs, the system comprising: The first module is used to obtain the node set and edge set of the knowledge graph, as well as the canvas size. The nodes in the node set have business hierarchy attributes, and the edge set represents the connection relationships between nodes. This module corresponds to step 100 in the method embodiment, solving the problem of lacking structured business attribute definitions and achieving standardized acquisition of basic data.

[0050] The second module is used to construct multiple geometric constraint regions that correspond one-to-one with the business hierarchy attributes based on the canvas size and business hierarchy attributes; and to initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes. This module corresponds to step 200 in the method embodiment, solves the problems of hierarchical mixing and unreasonable initialization, and achieves physical isolation and reasonable initialization of the hierarchical space.

[0051] The third module calculates the resultant force on the node using the resultant force model and iteratively updates the node's initial coordinates based on the resultant force. When the iteration meets the convergence condition, it outputs the node's latest coordinates as static coordinate data. The resultant force includes at least edge constraint forces calculated based on the edge set, and region constraint forces used to confine the node within the geometric constraint region. This module corresponds to step 300 in the method embodiment, solving the problems of layout instability and constraint failure, and achieving high-precision and high-stability coordinate calculation.

[0052] The system provided in this embodiment is based on the same inventive concept as the method embodiment described above, and therefore has the same beneficial effects, which will not be repeated here.

[0053] Thirdly, embodiments of this application provide a relation constraint layout device for a knowledge graph. The relation constraint layout device for a knowledge graph can be a personal computer (PC), a laptop computer, a server, or other device with data processing capabilities.

[0054] In this embodiment of the application, the relation constraint layout device for the knowledge graph may include a processor, a memory, a communication interface, and a communication bus.

[0055] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.

[0056] The communication interface includes input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting devices within the knowledge graph relation constraint layout device, as well as interfaces used for interconnecting the knowledge graph relation constraint layout device with other devices (such as other computing devices or user devices). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user devices can be displays, keyboards, etc.

[0057] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.

[0058] The processor can be a general-purpose processor, which can call the relation constraint layout program of the knowledge graph stored in memory and execute the relation constraint layout method of the knowledge graph provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the relation constraint layout program of the knowledge graph is called can be referred to the various embodiments of the relation constraint layout method of the knowledge graph in this application, and will not be repeated here.

[0059] Fourthly, embodiments of this application also provide a computer-readable storage medium.

[0060] The present application stores a knowledge graph relation constraint layout program on a computer-readable storage medium, wherein when the knowledge graph relation constraint layout program is executed by a processor, it implements the steps of the knowledge graph relation constraint layout method as described above.

[0061] The method implemented when the relation constraint layout procedure of the knowledge graph is executed can be referred to in the various embodiments of the relation constraint layout method of the knowledge graph in this application, and will not be repeated here.

[0062] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0063] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.

[0064] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.

[0065] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.

[0066] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0067] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.

[0068] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for relationship constraint layout of a knowledge graph, characterized in that, It includes: Obtain the node set and edge set of the knowledge graph, as well as the canvas size; wherein, the nodes in the node set have business level attributes, and the edge set is used to represent the connection relationship between the nodes; Based on the canvas size and the business level attribute, construct multiple geometric constraint regions that correspond one-to-one with the business level attribute; initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes; The resultant force on a node is calculated using a resultant force model, and the initial coordinates of the node are iteratively updated based on the resultant force. When the iteration meets the convergence condition, the latest coordinates of the node are output and used as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set and the region constraint force used to confine the node within the geometric constraint region.

2. The knowledge graph relation constraint layout method as described in claim 1, characterized in that: The business hierarchy attributes of the node include level one, level two, and level three; Based on the canvas size and the business hierarchy attribute, construct multiple geometric constraint regions that correspond one-to-one with the business hierarchy attribute, including: Using the canvas center point determined by the canvas size as a common center, construct three concentric elliptical rings; The inner elliptical ring is used to constrain nodes with a business level attribute of level one; the middle elliptical ring is used to constrain nodes with a business level attribute of level two; and the outer elliptical ring is used to constrain nodes with a business level attribute of level three. The radii of the middle and inner elliptical rings are obtained by scaling the radius of the outer elliptical ring.

3. The knowledge graph relation constraint layout method as described in claim 2, characterized in that, Initializing the nodes in the node set to the corresponding geometric constraint regions includes: Nodes with a business level attribute of level one are sorted by stable identifier and evenly distributed along the inner elliptical ring. The parent node is determined based on the connection relationship between nodes with a business hierarchy attribute of level two and nodes with a business hierarchy attribute of level one. Secondary nodes located under the same first-level parent node are initialized to the same sector within the elliptical ring of the middle layer. The central angle of the sector is determined by the position of the corresponding first-level parent node on the inner elliptical ring. When the number of secondary nodes in the same sector exceeds the preset single ring capacity, a supplementary ring is generated within the radial range of the elliptical ring of the middle layer to arrange the secondary nodes.

4. The method of claim 3, wherein, Initializing the nodes in the node set to the corresponding geometric constraint regions further includes: Find the second-level parent node that is associated with the third-level node; If there are multiple second-level parent nodes, obtain the coordinates of all second-level parent nodes relative to the center point of the canvas, calculate the average direction angle, use the average direction angle as the sector center angle of the third-level node, and initialize the third-level node to the corresponding sector within the outer elliptical ring. If there is no second-level parent node, the third-level node is assigned to the pre-defined bottom sector within the outer elliptical ring.

5. The method of claim 2, wherein, Calculating edge constraint forces based on the aforementioned edge set includes: For each edge in the edge set, set the corresponding target distance and weight coefficient for the business level attributes of the two nodes connected by each edge. The edge constraint force is calculated based on the target distance and weighting coefficient; Specifically, the target distance between the edge between the second-level node and the third-level node is less than the target distance between the edge between the first-level node and the second-level node, and the weight coefficient of the edge between the second-level node and the third-level node is greater than the weight coefficient of the edge between the first-level node and the second-level node.

6. The method of claim 5, wherein, The resultant force on the nodes is calculated using the resultant force model, specifically including: Obtain the node spacing between two nodes, and determine whether a node exceeds the boundary of its geometric constraint region; When the distance between the nodes is less than the safety threshold, the collision avoidance force between the two nodes is calculated. When it exceeds the boundary of its geometric constraint region, calculate the region constraint force of its geometric constraint region; The collision avoidance force is used as a repulsive force, the region constraint force is used as a restoring force pointing towards the center of the geometric constraint region, and the resultant force is obtained by combining the edge constraint force.

7. The knowledge graph relation constraint layout method as described in claim 5, characterized in that, The initial coordinates of the node are iteratively updated based on the resultant force, including: During the iteration process, a temperature coefficient and a maximum displacement per cycle that decrease with the iteration progress are set. The displacement vector of the node is calculated based on the resultant force, and the magnitude of the displacement vector is limited by the temperature coefficient and the maximum displacement of the single wheel. The initial coordinates of the node are updated based on the constrained displacement vector.

8. The knowledge graph relation constraint layout method as described in claim 1, characterized in that, After outputting the latest coordinates of the nodes and using them as static coordinate data, it also includes: The static coordinate data is sent to the front-end rendering engine, and then an instruction is sent to make the front-end rendering engine draw nodes and edges directly based on the static coordinate data, disabling continuous force-guided layout calculations on the browser side.

9. A relation constraint layout system for a knowledge graph, characterized in that, It includes: The first module is used to obtain the node set and edge set of the knowledge graph, as well as the canvas size; wherein, the nodes in the node set have business level attributes, and the edge set is used to represent the connection relationship between the nodes; The second module is used to construct multiple geometric constraint regions that correspond one-to-one with the business level attributes based on the canvas size and the business level attributes; and to initialize the nodes in the node set to the corresponding geometric constraint regions to obtain the initial coordinates of the nodes. The third module is used to calculate the resultant force on the node using the resultant force model, and to iteratively update the initial coordinates of the node according to the resultant force. When the iteration meets the convergence condition, the latest coordinates of the node are output as static coordinate data. The resultant force includes at least the edge constraint force calculated based on the edge set, and the region constraint force used to confine the node within the geometric constraint region.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 8.