Network topology visualization automatic layout method, device and equipment and storage medium
Patent Information
- Application Number
- CN202311491873.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-11-09
AI Technical Summary
[0004]本申请提供一种网络拓扑可视化自动布局方法、装置、设备及存储介质,用以解决现有技术需人工手动设置K值,在未知节点数量以及分布情况下无法确定较为相匹配的K值易陷入局部最优解,最终呈现出来的可视化效果较差的问题
[0037]本申请提供的一种网络拓扑可视化自动布局方法、装置、设备及存储介质,通过获取网络图中各节点的信息数据,所述信息数据中包括节点坐标;基于所述网络图中各节点的节点坐标确定所述网络图的矩形面积,根据所述矩形面积和节点总数计算得到节点密度值;按预设的面积划分规则将所述矩形面积进行区间划分,获得多个区间面积,获取各区间面积中的节点数量,并基于各区间面积中的节点数量计算节点分布不平衡度;基于所述节点密度值和所述节点分布不平衡度计算K均值聚类算法中的目标K值;采用目标K值,利用K均值聚类算法对所述网络图中各节点进行分类,生成网络拓扑图,并将所述网络拓扑图进行可视化呈现,通过构建由节点密度值和节点分布不平衡度作为变量的K值的关系式,根据节点分布的情况进行K值赋值,提高K均值聚类算法的准确性,提供较优的网络拓扑布局,提升可视化呈现的效果。
Smart Images

Figure CN117376154B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, device and storage medium for automatic network topology visualization layout. Background Technology
[0002] With the continuous development of networks, network visualization has become an inevitable evolutionary direction. Presenting the logical and physical structure of a network based on its topology makes the connections between topology nodes more intuitive, greatly improving operational efficiency. Existing network topology generation technologies employ various algorithms, each with its own strengths and weaknesses. Among them, the K-means clustering algorithm is an unsupervised learning-based clustering algorithm. Its basic principle is to divide a given dataset into K clusters by measuring the Euclidean distance and similarity between data objects. Similarity is inversely proportional to the distance between data objects; the greater the similarity, the smaller the distance. This process effectively presents the connections between different topology nodes.
[0003] However, in the application of the K-Means clustering algorithm, the number of clusters K is a hyperparameter that needs to be determined manually. Different K values result in completely different clustering results, and even a small amount of noisy data can have a significant impact on the average value. Therefore, the algorithm is prone to being less objective and accurate due to limitations in the selection of K values. When the number and distribution of nodes are unknown, it is difficult to determine a suitable K value, which can easily lead to getting trapped in local optima and ultimately result in poor visualization effects. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for automatic layout of network topology visualization, which solves the problem that the existing technology requires manual setting of the K value, and it is easy to get trapped in local optima when the number and distribution of nodes are unknown, resulting in poor visualization effect.
[0005] Firstly, this application provides a method for automatically laying out network topology visualization, including:
[0006] Obtain information data of each node in the network graph, including node coordinates;
[0007] The rectangular area of the network graph is determined based on the node coordinates of each node in the network graph, and the node density value is calculated based on the rectangular area and the total number of nodes.
[0008] The rectangular area is divided into intervals according to a preset area division rule to obtain multiple interval areas. The number of nodes in each interval area is obtained, and the node distribution imbalance is calculated based on the number of nodes in each interval area.
[0009] The target K value in the K-means clustering algorithm is calculated based on the node density value and the node distribution imbalance.
[0010] Using a target K value, the K-means clustering algorithm is used to classify the nodes in the network graph, generate a network topology graph, and then visualize the network topology graph.
[0011] Optionally, in the method described above, determining the rectangular area of the network graph based on the node coordinates of each node in the network graph includes:
[0012] Confirm the maximum x-coordinate value among the node coordinates of each node. max and minimum value x min And the maximum value of the y-coordinate y max and minimum value y min ;
[0013] Calculate the maximum value of the x-coordinate x. max and minimum value x min The first difference between them, and the maximum value of the y-coordinate. max and minimum value y min The second difference between them;
[0014] The length and width of the rectangle are determined based on the first difference and the second difference, thereby calculating the rectangular area of the network graph.
[0015] Optionally, in the method described above, calculating the node density value based on the area of the rectangle and the total number of nodes includes:
[0016] The ratio of the number of nodes to the area of the rectangle is used as the node density value.
[0017] Optionally, in the method described above, dividing the rectangular area into intervals according to a preset area division rule includes:
[0018] Based on the length and width of the rectangle, the rectangle area is divided into four intervals of equal size according to the four quadrants;
[0019] According to the naming order of the four quadrants, the first interval, the second interval, the third interval, and the fourth interval are obtained respectively.
[0020] Optionally, in the method described above, calculating the node distribution imbalance based on the number of nodes in each interval area includes:
[0021] Calculate the standard deviation of the interval relative to the area of the rectangle based on the number of nodes and the number of intervals in each interval area;
[0022] The ratio of the standard deviation to the area of the rectangle is used as the node distribution imbalance.
[0023] Optionally, in the method described above, calculating the target K value in the K-means clustering algorithm based on the node density value and the node distribution imbalance includes:
[0024] The product of the node density value and the preset area unit value is used as the first variable;
[0025] The product of the node distribution imbalance degree and the preset area unit value is used as the second variable;
[0026] The first variable, the second variable, and the preset minimum limit of K value are summed to obtain the sum value. The sum value is then rounded down to obtain the target K value.
[0027] Optionally, the method described above, after obtaining the information data of each node in the network graph, further includes:
[0028] The information data is formatted uniformly, and the formatted information data includes the ID, name, group, and coordinates of the node data.
[0029] Secondly, this application provides a network topology visualization automatic layout device, comprising:
[0030] A node acquisition module is used to acquire information data of each node in the network graph, including node coordinates.
[0031] The node density value calculation module is used to determine the rectangular area of the network graph based on the node coordinates of each node in the network graph, and calculate the node density value based on the rectangular area and the total number of nodes.
[0032] The node distribution imbalance calculation module is used to divide the rectangular area into intervals according to a preset area division rule to obtain multiple interval areas, obtain the number of nodes in each interval area, and calculate the node distribution imbalance based on the number of nodes in each interval area.
[0033] The target K-value calculation module is used to calculate the target K-value in the K-means clustering algorithm based on the node density value and the node distribution imbalance.
[0034] The network topology graph generation module is used to classify the nodes in the network graph using the K-means clustering algorithm with a target K value, generate a network topology graph, and visualize the network topology graph.
[0035] Thirdly, this application provides an electronic device, including a memory, a processor, and computer-executable instructions stored in the memory and executable on the processor, wherein the processor executes the computer-executable instructions to implement the network topology visualization automatic layout method described in any one of the first aspects above.
[0036] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the network topology visualization automatic layout method described in any one of the first aspects above.
[0037] This application provides a method, apparatus, device, and storage medium for automatic network topology visualization layout. The method involves acquiring information data of each node in a network graph, including node coordinates; determining the rectangular area of the network graph based on the node coordinates; calculating the node density value based on the rectangular area and the total number of nodes; dividing the rectangular area into intervals according to a preset area division rule to obtain multiple interval areas; obtaining the number of nodes in each interval area; calculating the node distribution imbalance based on the number of nodes in each interval area; calculating the target K-value in a K-means clustering algorithm based on the node density value and the node distribution imbalance; using the target K-value, classifying each node in the network graph using the K-means clustering algorithm to generate a network topology graph; and visualizing the network topology graph. By constructing a relationship between the node density value and the node distribution imbalance as variables for the K-value, and assigning K-values according to the node distribution, the accuracy of the K-means clustering algorithm is improved, providing a better network topology layout and enhancing the visualization effect. Attached Figure Description
[0038] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0039] Figure 1 This is a schematic diagram illustrating an application scenario of the network topology visualization and automatic layout method provided in this application embodiment.
[0040] Figure 2 A flowchart of the network topology visualization automatic layout method provided in the embodiments of this application.
[0041] Figure 3 This is a schematic diagram of a network topology visualization automatic layout device provided in an embodiment of this application.
[0042] Figure 4 A schematic diagram of the structure of an electronic device for a network topology visualization automatic layout device provided in an embodiment of this application.
[0043] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0044] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0045] In related technologies, automatic network topology layout algorithms are mainly divided into two categories: physical layout and logical layout. Physical layout maps the actual geographical locations of nodes (network devices) into virtual space, while logical layout is based on the network's connectivity and topology. Currently, various algorithms are used in the research of logical layout for network topology visualization, each with its own strengths and weaknesses. Among them, the K-Means clustering algorithm is an unsupervised learning type of clustering algorithm. Its basic principle is to divide the given dataset into K clusters by measuring the Euclidean distance (or Manhattan distance) and similarity index between data objects. The similarity is inversely proportional to the distance between data objects; the greater the similarity, the smaller the distance. However, the K-Means clustering algorithm is not objective and accurate enough due to the limitation of selecting the K value. It requires manual setting of the K value, and it is impossible to determine a suitable K value when the number and distribution of nodes are unknown. Different random seed points yield completely different clustering results and are prone to getting trapped in local optima. A small amount of noisy data can have a significant impact on the average value.
[0046] To address the aforementioned technical problems, this application aims to propose a method, apparatus, device, and storage medium for automatic network topology visualization layout. The core concept of the method lies in: constructing a relationship between the node density value and the node distribution imbalance degree as variables for the K value, assigning the K value according to the node distribution, improving the accuracy of the K-means clustering algorithm, providing a better network topology layout, and enhancing the visualization effect.
[0047] To better understand the solutions of the embodiments of this application, an application scenario involved in the embodiments of this application will be introduced below.
[0048] Please see Figure 1 , Figure 1This is a schematic diagram illustrating an application scenario of the network topology visualization and automatic layout method provided in the embodiments of this application, such as... Figure 1 As shown, the system includes a network environment 100 and a network management system (i.e., a network topology visualization and automatic layout device). Data reported by network elements within a domain of the network environment (such as alarm data) is uniformly reported to the network management system for collection. Specifically, the data is aggregated by the data acquisition module in the network management system (i.e., the network topology generation device, such as a server or computer). In the diagram, solid arrows represent data flows, and dashed arrows represent control signal flows (or message flows). Then, the network management system calls the intelligent classification module to perform correlation analysis on the collected data. For example, alarm data can be clustered into faults. Based on the identity document (ID) of the network elements reported by the data acquisition module, and combined with the topology map metadata, it obtains the node information (such as node coordinates) of each node. Based on the node coordinates, it determines the node density value and the node distribution imbalance. Further, based on the node density value and the node distribution imbalance, it calculates the target K value in the K-means clustering algorithm, thereby using the K-means clustering algorithm to classify each node and generate a target network topology map. The topology map metadata can be a global network topology map or other data used to determine the connection relationships between network elements. The node information indicates the nodes and connections between them calculated by the intelligent classification module. This target network topology map is then reported to the topology presentation module for visualization.
[0049] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0050] Figure 2 A flowchart illustrating the network topology visualization and automatic layout method provided in this application embodiment. Figure 2 As shown, the method in this embodiment includes:
[0051] S201: Obtain information data of each node in the network graph, including node coordinates.
[0052] The execution entity of this application embodiment can be a server, or a network topology visualization automatic layout system in the server, wherein the network topology visualization automatic layout system can be implemented by software.
[0053] Understandably, for each node in the network graph, the node information of each node can be obtained by combining the topology graph metadata. The node information may include the node coordinates of the node in the preset coordinate system.
[0054] S202: Determine the rectangular area of the network graph based on the node coordinates of each node in the network graph, and calculate the node density value based on the rectangular area and the total number of nodes.
[0055] In this step, node density is a measure of the number of nodes distributed within a certain area. Specifically, based on the node coordinates of each node, the maximum and minimum values of x and y are found, the difference between x and y is calculated, the area occupied by all nodes (with a rectangle as the standard shape) is calculated, and then the ratio of the number of nodes to the area of the rectangle is taken as the node density value.
[0056] S203: Divide the rectangular area into intervals according to the preset area division rules to obtain multiple interval areas, obtain the number of nodes in each interval area, and calculate the node distribution imbalance based on the number of nodes in each interval area.
[0057] In this step, there are many ways to divide the rectangular area into intervals. The rectangular area can be divided according to the four-quadrant division rule, or it can be divided according to other equal division methods, so as to obtain at least two intervals with equal area.
[0058] For each interval area, the number of nodes contained therein can be counted. Combined with the number of intervals, the standard deviation of the interval relative to the area of the rectangle can be calculated. The ratio of the standard deviation to the area of the rectangle is used as the node distribution imbalance.
[0059] S204: Calculate the target K value in the K-means clustering algorithm based on the node density value and the node distribution imbalance.
[0060] In this step, the target K value can be calculated using a formula based on the node density value and the node distribution imbalance:
[0061] K = int(node density value + node distribution imbalance degree + minimum limit of K value),
[0062] The int() function is an integer function.
[0063] S205: Using the target K value, the K-means clustering algorithm is used to classify each node in the network graph, generate a network topology graph, and then visualize the network topology graph.
[0064] Understandably, using the K-means clustering algorithm, the nodes in the network graph are pre-divided into K groups. K objects are then randomly selected as initial cluster centers. The distance between each object and each seed cluster center is calculated, and each object is assigned to the nearest cluster center. Each time a sample is assigned, the cluster centers are recalculated based on the existing objects in the cluster. This process is repeated until a termination condition is met. The termination condition could be that no (or a minimum number) objects are reassigned to different clusters, no (or a minimum number) cluster centers change, or the sum of squared errors reaches a local minimum. After reaching the termination condition, the relationships between the nodes are used to generate a network topology graph and present it.
[0065] The network topology visualization automatic layout method provided in this embodiment acquires information data of each node in the network graph, including node coordinates; determines the rectangular area of the network graph based on the node coordinates, and calculates the node density value based on the rectangular area and the total number of nodes; divides the rectangular area into intervals according to a preset area division rule to obtain multiple interval areas, obtains the number of nodes in each interval area, and calculates the node distribution imbalance based on the number of nodes in each interval area; calculates the target K value in the K-means clustering algorithm based on the node density value and the node distribution imbalance; uses the target K value to classify each node in the network graph using the K-means clustering algorithm, generates a network topology graph, and visualizes the network topology graph. By constructing a relationship between the node density value and the node distribution imbalance as variables for the K value, and assigning K values according to the node distribution, the accuracy of the K-means clustering algorithm is improved, providing a better network topology layout and enhancing the visualization effect.
[0066] The technical solution of the above-mentioned network topology visualization automatic layout method is described in detail below.
[0067] In one possible implementation, the network topology visualization automatic layout method provided in this embodiment calculates the rectangular area of the network graph by calculating the first difference between the x-coordinates and the second difference between the y-coordinates of the nodes in each node, and further calculates the node density value within the rectangular area.
[0068] Specifically, determining the rectangular area of the network graph based on the node coordinates of each node in the network graph includes: identifying the maximum value x of the x-coordinate among the node coordinates of each node. max and minimum value x min And the maximum value of the y-coordinate y max and minimum value y min ; Calculate the maximum value of the x-coordinate x max and minimum value x minThe first difference between them, and the maximum value of the y-coordinate. max and minimum value y min The second difference between the first and second differences is used to determine the length and width of the rectangle area, thereby calculating the rectangular area of the network graph.
[0069] Further, the step of calculating the node density value based on the area of the rectangle and the total number of nodes includes: using the ratio of the number of nodes to the area of the rectangle as the node density value.
[0070] Understandably, the node density value refers to the average number of nodes contained in each area unit. Therefore, it is necessary to first calculate the total area (that is, the size of the rectangle) and then calculate the ratio of the number of nodes to the area of the rectangle.
[0071] In this embodiment, based on the node coordinates of each node, a range (rectangle) can be defined in a two-dimensional plane. The boundary of this range is the maximum value x in the x-coordinate. max and minimum value x min The distance between them, and the maximum value y on the y-coordinate. max and minimum value y min It is determined by the difference between them.
[0072] In this embodiment, the rectangular area of the network graph is calculated by calculating the first difference between the x-coordinates and the second difference between the y-coordinates of the nodes in each node. The node density value within the rectangular area is then calculated, which helps to define the range of cluster centers in the K-means clustering algorithm, making the randomly generated cluster centers closer to the node set and improving the accuracy and stability of the clustering results.
[0073] In one possible implementation, the network topology visualization automatic layout method provided in this embodiment divides the rectangular area into four equal-area intervals using a four-quadrant division rule, counts the number of nodes in each interval, calculates the standard deviation of the interval relative to the rectangular area, and further calculates the node distribution imbalance.
[0074] The step of dividing the rectangular area into intervals according to the preset area division rules includes: dividing the rectangular area into four intervals of equal size according to the length and width of the rectangular area; and obtaining the first interval, the second interval, the third interval, and the fourth interval according to the naming order of the four quadrants.
[0075] Furthermore, the step of calculating the node distribution imbalance based on the number of nodes in each interval area includes: calculating the standard deviation of the interval relative to the rectangular area based on the number of nodes in each interval area and the number of intervals; and using the ratio of the standard deviation to the rectangular area as the node distribution imbalance.
[0076] Based on the coordinates of each node, the number of nodes in each interval is recorded. Finally, the standard deviation of the four intervals is calculated. The standard deviation can be understood as the difference between the average number of nodes in each interval and the average number of nodes. For example, if the standard deviation calculated from 100 random nodes is 4, it means that the number of nodes in these four intervals differs from the ideal number of nodes in a single interval (100 / 4) by 4. Since the total number of nodes is fixed, when the number of nodes in one interval is greater than the average, the extra nodes can only come from the other three intervals, thus reflecting the strength of the uneven distribution.
[0077] For example, suppose there are 100 nodes in the network graph (i.e., the area of the rectangle). The number of nodes in the first interval is 21, the second interval is 29, the third interval is 29, and the fourth interval is 21. This means that 4 nodes from the first interval have moved to either the second or third interval, and 4 nodes from the fourth interval have moved to either the second or third interval. The standard deviation is calculated to be 4 based on the number of nodes in each region. When calculating the node distribution imbalance, considering that this is caused by these 8 (4+4) nodes, we can assume that the actual number of nodes in each region is offset by 8 (standard deviation * 2) nodes compared to the ideal situation. The specific calculation method for the node distribution imbalance is: Node distribution imbalance = (2 * standard deviation * number of intervals) / area of rectangle.
[0078] In this embodiment, the rectangular area is divided into four equal-area intervals by the four-quadrant division rule. The number of nodes in each interval is counted, the standard deviation of the interval relative to the rectangular area is calculated, and the node distribution imbalance is further calculated. This can reflect the strength of the uneven distribution of nodes, thereby correcting the accuracy of the target K value.
[0079] In one possible implementation, the network topology visualization automatic layout method provided in this embodiment constructs a calculation formula for the target K value based on the node density value and the node distribution imbalance, and assigns the K value according to the node distribution.
[0080] Specifically, calculating the target K value in the K-means clustering algorithm based on the node density value and the node distribution imbalance includes: using the product of the node density value and a preset area unit value as a first variable; using the product of the node distribution imbalance and a preset area unit value as a second variable; accumulating the first variable, the second variable, and a preset minimum K value limit to obtain an accumulated value; and rounding the accumulated value to obtain the target K value.
[0081] The formula for calculating the target K value is constructed based on the node density value and the node distribution imbalance:
[0082] K = int(first variable + second variable + minimum value of K), where int() is the integer function.
[0083] If the preset area unit value is 100, then the first variable = node density value * 100. Generally speaking, if the value of the first variable is 1, it means that there is one node on average in every 100 area units. The node distribution is relatively loose and the visualization is high.
[0084] The second variable represents the ratio of the number of offset nodes to the number of ideal nodes in a single region. When the number of offset nodes is much smaller than the number of ideal nodes in a region, the value of the second variable is close to 0, indicating that the standard deviation is very small or the overall area is very large and the node distribution is very uniform, so there is no need to increase the value of K (i.e., it is 0). When the number of offset nodes is much larger than the number of ideal nodes in a single region, it indicates that there are too many offset nodes, or even that the number of ideal nodes in a single region is exceeded, so the value of K needs to be increased proportionally according to the calculation results.
[0085] The minimum limit of K in the calculation formula represents the minimum value of K. Because the node density is very low and the distribution is uniform during the test, the value calculated by "first variable + second variable" tends to 0. Therefore, a minimum limit of K needs to be set to ensure the minimum number of clusters. The minimum limit of K is also derived from the number of intervals divided by the rectangle. For example, the minimum can be grouped into four clusters.
[0086] It should be noted that when the number of nodes in the data file is large and the distribution of nodes is uneven, the target K value may be close to the number of nodes, resulting in too many cluster colors and a small number of nodes in each cluster. This is the result of continuous iteration, but in reality, this violates the original intention of visualization. Therefore, in order to ensure the relationship between the dependent and independent variables while also paying attention to the visualization effect, a maximum limit for the K value is set according to the specific number of nodes, that is, the square root of the number of nodes. For example, if there are 100 nodes, the node density is too high and the node distribution is highly unbalanced, the calculated K value is 25, but due to the conditional constraints, the returned K value is 10.
[0087] In this embodiment, by constructing a calculation formula for the target K value based on the node density value and the node distribution imbalance, and assigning the target K value according to the node distribution, a reasonable K value can be obtained, thus improving the accuracy of the K value setting.
[0088] In one possible implementation, considering that the data of each node in the topology graph metadata may need to be preprocessed before it can be used for subsequent calculations, the automatic layout method for network topology visualization provided in this embodiment further includes, after obtaining the information data of each node in the network graph: standardizing the format of the information data, wherein the standardized information data includes the ID, name, group and coordinates of the node data.
[0089] Understandably, node information data needs to be filled in or modified according to a fixed format. The value list obtained from the topology graph metadata includes information about all nodes. Each node's information data is a dictionary, where the keys are id, name, group (default is 1), and coordinate, referring to the node's ID, name, group, and coordinates, respectively. Besides distinguishing different nodes, the ID is crucial for recording the connection status of each node in links (the link's value is also a list, recording the connection status of each node, where the keys are source, target, and value. Source and target represent the starting and target nodes, respectively, and value represents the bandwidth between the two nodes; most nodes have the same bandwidth). The coordinate data requires the user to pre-establish a two-dimensional coordinate system, assigning corresponding coordinate values based on the positional differences between nodes. Note that the assigned values must be integers. This data serves as the primary basis for the backend network topology visualization algorithm calculation and is also the source for calculating the group value of each node.
[0090] In this embodiment, standardizing the format of the information data facilitates subsequent data processing and improves the stability of the algorithm.
[0091] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0092] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0093] Figure 3 This is a schematic diagram of a network topology visualization and automatic layout device provided in an embodiment of this application. Figure 3 As shown, the network topology visualization and automatic layout device includes:
[0094] The node acquisition module 31 is used to acquire information data of each node in the network graph, including node coordinates.
[0095] The node density value calculation module 32 is used to determine the rectangular area of the network graph based on the node coordinates of each node in the network graph, and calculate the node density value based on the rectangular area and the total number of nodes.
[0096] The node distribution imbalance calculation module 33 is used to divide the rectangular area into intervals according to a preset area division rule, obtain multiple interval areas, obtain the number of nodes in each interval area, and calculate the node distribution imbalance based on the number of nodes in each interval area.
[0097] The target K-value calculation module 34 is used to calculate the target K-value in the K-means clustering algorithm based on the node density value and the node distribution imbalance.
[0098] The network topology generation module 35 is used to classify each node in the network graph using a target K value and a K-means clustering algorithm to generate a network topology graph and then visualize the network topology graph.
[0099] In one possible design, the node density value calculation module 32 is specifically used for:
[0100] Confirm the maximum x-coordinate value among the node coordinates of each node. max and minimum value x min And the maximum value of the y-coordinate y max and minimum value y min ;
[0101] Calculate the maximum value of the x-coordinate x. maxand minimum value x min The first difference between them, and the maximum value of the y-coordinate. max and minimum value y min The second difference between them;
[0102] The length and width of the rectangle are determined based on the first difference and the second difference, thereby calculating the rectangular area of the network graph.
[0103] In one possible design, the node density value calculation module 32 is specifically used for:
[0104] The ratio of the number of nodes to the area of the rectangle is used as the node density value.
[0105] In one possible design, the node distribution imbalance calculation module 33 is specifically used for:
[0106] Based on the length and width of the rectangle, the rectangle area is divided into four intervals of equal size according to the four quadrants;
[0107] According to the naming order of the four quadrants, the first interval, the second interval, the third interval, and the fourth interval are obtained respectively.
[0108] In one possible design, the node distribution imbalance calculation module 33 is specifically used for:
[0109] Calculate the standard deviation of the interval relative to the area of the rectangle based on the number of nodes and the number of intervals in each interval area;
[0110] The ratio of the standard deviation to the area of the rectangle is used as the node distribution imbalance.
[0111] In one possible design, the target K value calculation module 34 is specifically used for:
[0112] The product of the node density value and the preset area unit value is used as the first variable;
[0113] The product of the node distribution imbalance degree and the preset area unit value is used as the second variable;
[0114] The first variable, the second variable, and the preset minimum limit of K value are summed to obtain the sum value. The sum value is then rounded down to obtain the target K value.
[0115] In one possible design, the node acquisition module 31 is specifically used for:
[0116] The information data is formatted uniformly, and the formatted information data includes the ID, name, group, and coordinates of the node data.
[0117] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0118] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or in the form of software program modules.
[0119] Figure 4 This is a schematic diagram of the electronic device for the network topology visualization and automatic layout apparatus provided in an embodiment of this application. Figure 4 As shown, the electronic device of this embodiment includes: at least one processor 40 ( Figure 4 (Only one is shown) a processor, a memory 41, and a computer program stored in the memory 41 that can run on at least one processor 40, which executes the computer program to implement the steps in any of the above method embodiments.
[0120] The electronic device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that... Figure 4 This is merely an example of an electronic device and does not constitute a limitation on electronic devices. It may include more or fewer components than shown in the illustration, or combinations of certain components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0121] The processor 40 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0122] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0123] In some embodiments, memory 41 may be an internal storage unit of an electronic device, such as the memory of the electronic device. In other embodiments, memory 41 may be an external storage device of the electronic device, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc. Furthermore, memory 41 may include both internal and external storage units of the electronic device. Memory 41 is used to store operating systems, applications, bootloaders, data, and other programs, such as program code for computer programs. Memory 41 can also be used to temporarily store data that has been output or will be output.
[0124] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps described in the various method embodiments above.
[0125] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0126] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an application-specific integrated circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the aforementioned electronic device.
[0127] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0128] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0129] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0130] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for automatically laying out network topology visually, characterized in that, include: Obtain information data of each node in the network graph, including node coordinates; The rectangular area of the network graph is determined based on the node coordinates of each node in the network graph, and the node density value is calculated based on the rectangular area and the total number of nodes. The rectangular area is divided into intervals according to a preset area division rule to obtain multiple interval areas. The number of nodes in each interval area is obtained, and the node distribution imbalance is calculated based on the number of nodes in each interval area. The target K value in the K-means clustering algorithm is calculated based on the node density value and the node distribution imbalance. Using a target K value, the K-means clustering algorithm is used to classify the nodes in the network graph, generate a network topology graph, and then visualize the network topology graph. The calculation of the target K value in the K-means clustering algorithm based on the node density value and the node distribution imbalance includes: The product of the node density value and the preset area unit value is used as the first variable; The product of the node distribution imbalance degree and the preset area unit value is used as the second variable; The first variable, the second variable, and the preset minimum limit of K value are summed to obtain the sum value. The sum value is then rounded down to obtain the target K value.
2. The method according to claim 1, characterized in that, Determining the rectangular area of the network graph based on the node coordinates of each node in the network graph includes: Confirm the maximum x-coordinate value among the node coordinates of each node. max and minimum value x min And the maximum value of the y-coordinate y max and minimum value y min ; Calculate the maximum value of the x-coordinate x. max and minimum value x min The first difference between them, and the maximum value of the y-coordinate. max and minimum value y min The second difference between them; The length and width of the rectangle are determined based on the first difference and the second difference, thereby calculating the rectangular area of the network graph.
3. The method according to claim 1, characterized in that, The calculation of the node density value based on the area of the rectangle and the total number of nodes includes: The ratio of the number of nodes to the area of the rectangle is used as the node density value.
4. The method according to claim 1, characterized in that, The step of dividing the rectangular area into intervals according to a preset area division rule includes: Based on the length and width of the rectangle, the rectangle area is divided into four intervals of equal size according to the four quadrants; According to the naming order of the four quadrants, the first interval, the second interval, the third interval, and the fourth interval are obtained respectively.
5. The method according to claim 4, characterized in that, The calculation of node distribution imbalance based on the number of nodes in each interval area includes: Calculate the standard deviation of the interval relative to the area of the rectangle based on the number of nodes and the number of intervals in each interval area; The ratio of the standard deviation to the area of the rectangle is used as the node distribution imbalance.
6. The method according to claim 1, characterized in that, After obtaining the information data of each node in the network graph, the process also includes: The information data is formatted uniformly, and the formatted information data includes the ID, name, group, and coordinates of the node data.
7. A network topology visualization and automatic layout device, characterized in that, include: A node acquisition module is used to acquire information data of each node in the network graph, including node coordinates. The node density value calculation module is used to determine the rectangular area of the network graph based on the node coordinates of each node in the network graph, and calculate the node density value based on the rectangular area and the total number of nodes. The node distribution imbalance calculation module is used to divide the rectangular area into intervals according to a preset area division rule to obtain multiple interval areas, obtain the number of nodes in each interval area, and calculate the node distribution imbalance based on the number of nodes in each interval area. The target K-value calculation module is used to calculate the target K-value in the K-means clustering algorithm based on the node density value and the node distribution imbalance. The network topology generation module is used to classify the nodes in the network graph using the K-means clustering algorithm with a target K value, generate a network topology graph, and visualize the network topology graph. The target K value calculation module is specifically used for: The product of the node density value and the preset area unit value is used as the first variable; The product of the node distribution imbalance degree and the preset area unit value is used as the second variable; The first variable, the second variable, and the preset minimum limit of K value are summed to obtain the sum value. The sum value is then rounded down to obtain the target K value.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Hierarchical random walk sampling method based on clustering coefficients of node neighborhoods
CN113901984A
Method and device for determining network topological graph, equipment and storage medium
CN115550190A