CN111241348A - Method for dynamically adjusting Tree spacing based on Walker's Tree - Google Patents
Method for dynamically adjusting Tree spacing based on Walker's Tree Download PDFInfo
- Publication number
- CN111241348A CN111241348A CN201911410941.1A CN201911410941A CN111241348A CN 111241348 A CN111241348 A CN 111241348A CN 201911410941 A CN201911410941 A CN 201911410941A CN 111241348 A CN111241348 A CN 111241348A
- Authority
- CN
- China
- Prior art keywords
- tree
- node
- nodes
- traversal
- layer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 28
- 239000010410 layer Substances 0.000 claims description 38
- 238000000926 separation method Methods 0.000 claims description 11
- 239000011229 interlayer Substances 0.000 claims description 8
- 238000013507 mapping Methods 0.000 abstract description 2
- 230000010365 information processing Effects 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 238000003672 processing method Methods 0.000 description 2
- 230000003796 beauty Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Image Generation (AREA)
Abstract
The invention discloses a method for dynamically adjusting Tree spacing based on Walker's Tree, and relates to the field of automatic mapping of a structure Tree. The proposal of the Walker's Tree algorithm effectively solves the two problems that the width of a drawing Tree is very wide and the parent node in the Tree is not the central position of all the child nodes, and has the only disadvantage that the dynamic adjustment of the space in the Tree is not considered. The method comprises the following steps: 1) carrying out data topology information processing; 2) establishing a tree structure model; 3) performing subsequent traversal on all nodes in the tree model, and calculating an initial value and an adjustment value of each node coordinate in the tree; 4) performing preamble traversal, and calculating the final coordinate of each node in the tree; 5) the graph of the tree is output. The method not only ensures the symmetry of the father node with respect to the child nodes, but also ensures that the spacing of the tree structure can be dynamically adjusted according to the size of the nodes, and can meet the requirements that the nodes in the tree are different in size, the tree structure is not crowded and is tidy as a whole, and the perfect tree graph output is realized.
Description
Technical Field
The invention relates to the field of automatic mapping of a structure Tree, in particular to a method for dynamically adjusting Tree spacing based on Walker's Tree.
Background
The key task of drawing a tree is to determine the location of each node in the tree. The rendering tree algorithm is primarily to compute the x and y coordinates of each node of the tree. These coordinates can then be used to draw the tree. Where the node location algorithm must solve two key problems. First, the overall beauty of the tree is drawn. Secondly, the node location algorithm should save space. Each of these two problems can be handled directly, but combining them together presents some challenges.
The tree-drawing algorithms proposed by many researchers also have the situation that the result of drawing the tree is unsatisfactory, and there are three main problems to be solved, namely 1) the width of the drawn tree is very wide; 2) the parent node in the tree is not centered on all its children nodes; 3) the distance between each layer in the tree is fixed and is a fixed constant, and the setting does not consider the influence generated between the sizes and the distances of the nodes of the upper layer and the lower layer.
The Walker's Tree algorithm effectively solves the first two problems, and has the only disadvantage that the dynamic adjustment of the intervals in the Tree is not considered, so that the Tree structure is integrally attractive, and meanwhile, the hierarchical structure of the Tree is not very high and has a very abrupt effect.
Disclosure of Invention
The technical problem to be solved and the technical task to be solved by the invention are to perfect and improve the prior technical scheme, and provide a method for dynamically adjusting the Tree spacing based on Walker's Tree, so as to achieve the purpose of dynamically adjusting the spacing in the Tree and realizing a perfect Tree diagram. Therefore, the invention adopts the following technical scheme.
A method for dynamically adjusting Tree spacing based on Walker's Tree comprises the following steps:
1) firstly, processing data topology information, establishing a tree node object, and initializing tree node attributes;
2) establishing a tree structure model, and processing the parent-child relationship of each node in the tree;
3) performing subsequent traversal on all nodes in the tree model, and calculating an initial value and an adjustment value of each node coordinate in the tree;
4) performing preamble traversal, and calculating the final coordinate of each node in the tree;
5) the graph of the tree is output.
The method not only ensures the symmetry of the father node with respect to the child nodes, but also ensures that the spacing of the tree structure can be dynamically adjusted according to the size of the nodes, and can meet the requirements that the nodes in the tree are different in size, the tree structure is not crowded and is tidy as a whole, and the perfect tree graph output is realized.
As a preferable technical means: in step 3), the adjustment value is set for the following cases: when the current node has a left brother node, the size and the node distance of the two nodes need to be considered in order to separate the two nodes by a certain distance; when the current node is a parent node of a subtree, whether child nodes of the current node intersect with nodes of other subtrees or not is considered layer by layer, and if so, the distances of the subtrees are pulled apart.
As a preferable technical means: in step 3), during the subsequent traversal, the first traversal starts from the leaf node of the smallest Subtree, recursively constructs a larger Subtree from left to right, wherein a certain distance sitting Separation between Sibling nodes is ensured, and a certain distance sitting Separation between adjacent subtrees is also ensured, when the traversal of the tree goes from the leaf node to the root node, it combines the smaller Subtree and the root node to form a larger Subtree, for a fixed node, the subtrees are moved and located from left to right, when one of the new subtrees is designed, the new subtrees are placed on the left of the neighbors until the new subtrees do not cross other nodes, the moving process starts from the root node of their subtrees, the subtrees are separated by the distance defined by sitting Separation, and then the next layer are separated by the distance defined by sutree Separation, this continues sequentially to the next level until the root node of the subtree is reached, and when the left and right descendants for the node are completed, the node is in the middle of all the children nodes on the left and all the children nodes on the right. And effectively realizing subsequent traversal, considering whether the subtree and the laid-out subtree have cross processing or not, and calculating the distance between adjacent nodes according to the sizes of the adjacent nodes.
As a preferable technical means: in step 4), before the pre-sequence traversal, tree nodes of each layer need to be traversed layer by layer, the sizes of all nodes of the layer are judged, the interlayer spacing of the previous layer is set according to the largest node, and after all the interlayer spacings are set, the pre-sequence traversal is performed to set the coordinates of each node. The process starts from the root node of the tree, and the value of the abscissa of the root node is added with the adjustment values of all ancestor nodes of the root node to obtain the coordinate value of the node. And the method effectively realizes the traversal of the front sequence and realizes the adjustment of the interlayer spacing of each layer according to the size of the layer nodes.
Has the advantages that: the method not only ensures the symmetry of the father node with respect to the child nodes, but also ensures that the spacing of the tree structure can be dynamically adjusted according to the size of the nodes, and can meet the requirements that the nodes in the tree are different in size, the tree structure is not crowded and is tidy as a whole, and the perfect tree graph output is realized.
Drawings
FIG. 1 is a schematic flow diagram of the present invention.
FIG. 2 is an exemplary tree diagram of the present invention for a next-order traversal and a previous-order traversal.
Detailed Description
The technical scheme of the invention is further explained in detail by combining the drawings in the specification.
As shown in fig. 1, a method for dynamically adjusting Tree spacing based on Walker's Tree includes the following steps:
1) firstly, processing data topology information, establishing a tree node object, and initializing tree node attributes;
2) establishing a tree structure model, and processing the parent-child relationship of each node in the tree, wherein the trees in the example are trees with only one root node;
3) and performing subsequent traversal, calculating an initial value and an adjustment value of each node coordinate in the tree, wherein the adjustment values are set according to the following conditions: when the current node has a left brother node, the size and the node distance of the two nodes need to be considered in order to separate the two nodes by a certain distance; when the current node is a parent node of a subtree, whether child nodes are crossed with nodes of other subtrees or not is considered layer by layer, and if the child nodes are crossed with the nodes of other subtrees, the distance of the subtrees is pulled open;
4) performing preamble traversal, and calculating the final coordinate of each node in the tree, wherein the direction of the tree is downward, so that the vertical coordinate of the tree node is mainly determined by the number of layers and the sizes of the upper and lower layers of nodes;
5) the graph of the tree is output.
The backward traversal and the forward traversal embody a process of dynamically adjusting the tree spacing. The subsequent traversal process not only determines the initial value and the adjustment value of each node coordinate, but also adjusts the distance between two nodes according to adjacent nodes. The step of forward traversal is to dynamically set the layer spacing of each layer according to the size of each layer of nodes and then determine the coordinate value of each node.
During the subsequent traversal, the first traversal starts from the leaf node of the smallest sub-tree, recursively constructs larger sub-trees from left to right, wherein a certain distance sitting Separation is ensured between Sibling nodes, and a certain distance sitting Separation is also ensured between adjacent sub-trees, when the traversal of the tree from leaf node to root node combines the smaller sub-tree with its root node to form a larger sub-tree, for a fixed node, the sub-trees are moved from left to right, positioned, when one of the new sub-trees is designed, and its new sub-tree is placed on the left of the new sub-tree and moved until the new sub-tree is not crossed with other nodes, the moving process starts with the root node of their sub-tree, the distance defined by Silbling Separation is separated, and the next layer is separated by the distance defined by Subseparation, and this continues to the next layer in turn, and when the left and right descendants of the node are finished, the node is positioned at the middle position of all the child nodes on the left side and all the child nodes on the right side.
The following are examples of backward-ordered traversal and forward-ordered traversal.
As shown in fig. 2, the next-order traversal sequence is: EIPHBCMNQRSGDA. From this sequence, the node that needs to be visited first is the left leaf node E. Since node E has no sibling nodes to the left, the prelimnaryValue of node E is set to 0 directly, and the initial value of modeefierrvalue is also set to 0. The next processing node is an I node, which is also a leaf node, and there is no left sibling node, so the preliminaryValue of node I is set to 0, and modifierValue is set to 0. Again the process is a leaf node P. P node is a leaf node, with a left sibling node I, so p.prelimnaryvalue = i.prelimnaryvalue + sibingseparation + treenode size = 0 + 4 + 2 = 6. When the processing node B is left mostnode = E (leftmost child node), right mostnode = E (rightmost child node), H node has no left sibling node, so b.prelimnaryvalue = (EprelimnaryValue + e.prelimnaryvalue)/2; and then proceeds to process node B (the processing method of the same node E). Node F is also a leaf node and therefore has the same processing method as node I. The node D and the node B are already a subtree. It is necessary to determine layer by layer whether the nodes of the lower layer will overlap. If there is a crossover and overlap, then the D subtree is moved a corresponding distance to avoid crossover and overlap.
Before the pre-sequence traversal, tree nodes of each layer need to be traversed layer by layer, the sizes of all the nodes of the layer are judged, the interlayer spacing of the previous layer is set according to the largest node, and the pre-sequence traversal is carried out after all the interlayer spacings are set to set the coordinates of all the nodes. The process starts from the root node of the tree, and the value of the abscissa of the root node is added with the adjustment values of all ancestor nodes of the root node to obtain the coordinate value of the node.
As shown in fig. 2, the precedence traversal sequence is: ABEHIPCDKGMNQRS. The abscissa of each node in the graph is taken to be its prelimnaryValue + All processors' modified value. The abscissa of each node in the graph can be calculated according to the process of the first subsequent traversal. For example: root node A: 13.5, B: prelimnaryvalue + a. modifiervalue = 3 + 0 = 3; ...
The invention is an improved algorithm which is provided on the basis of the Walker's Tree algorithm, and is used for dynamically adjusting the interlayer spacing of the Tree structure. The tree obtained in this way can meet the effects that the sizes of the nodes in the tree are different, the structure of the tree is not crowded, and the whole tree is neat and attractive.
The method for dynamically adjusting Tree spacing based on Walker's Tree shown in fig. 1-2 is a specific embodiment of the present invention, has embodied the outstanding substantive features and significant progress of the present invention, and can make equivalent modifications in shape, structure, etc. according to the practical use requirements and with the teaching of the present invention, all of which are within the protection scope of the present solution.
Claims (4)
1. A method for dynamically adjusting Tree spacing based on Walker's Tree is characterized by comprising the following steps:
1) firstly, processing data topology information, establishing a tree node object, and initializing tree node attributes;
2) establishing a tree structure model, and processing the parent-child relationship of each node in the tree;
3) performing subsequent traversal on all nodes in the tree model, and calculating an initial value and an adjustment value of each node coordinate in the tree;
4) performing preamble traversal, and calculating the final coordinate of each node in the tree;
5) the graph of the tree is output.
2. The method for dynamically adjusting Tree spacing based on Walker's Tree as claimed in claim 1, wherein: in step 3), the adjustment value is set for the following cases: when the current node has a left brother node, the size and the node distance of the two nodes need to be considered in order to separate the two nodes by a certain distance; when the current node is a parent node of a subtree, whether child nodes of the current node intersect with nodes of other subtrees or not is considered layer by layer, and if so, the distances of the subtrees are pulled apart.
3. The method for dynamically adjusting Tree spacing based on Walker's Tree as claimed in claim 1, wherein: in step 3), during the subsequent traversal, the first traversal starts from the leaf node of the smallest Subtree, recursively constructs a larger Subtree from left to right, wherein a certain distance sitting Separation between Sibling nodes is ensured, and a certain distance sitting Separation between adjacent subtrees is also ensured, when the traversal of the tree goes from the leaf node to the root node, it combines the smaller Subtree and the root node to form a larger Subtree, for a fixed node, the subtrees are moved and located from left to right, when one of the new subtrees is designed, the new subtrees are placed on the left of the neighbors until the new subtrees do not cross other nodes, the moving process starts from the root node of their subtrees, the subtrees are separated by the distance defined by sitting Separation, and then the next layer are separated by the distance defined by sutree Separation, this continues sequentially to the next level until the root node of the subtree is reached, and when the left and right descendants for the node are completed, the node is in the middle of all the children nodes on the left and all the children nodes on the right.
4. The method for dynamically adjusting Tree spacing based on Walker's Tree as claimed in claim 1, wherein: in step 4), before the pre-sequence traversal, tree nodes of each layer need to be traversed layer by layer, the sizes of all the nodes of the layer are judged, the interlayer spacing of the previous layer is set according to the largest node, and after all the interlayer spacings are set, the pre-sequence traversal is carried out to set the coordinates of each node; the process starts from the root node of the tree, and the value of the abscissa of the root node is added with the adjustment values of all ancestor nodes of the root node to obtain the coordinate value of the node.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911410941.1A CN111241348B (en) | 2019-12-31 | 2019-12-31 | Method for dynamically adjusting Tree spacing based on Walker's Tree |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911410941.1A CN111241348B (en) | 2019-12-31 | 2019-12-31 | Method for dynamically adjusting Tree spacing based on Walker's Tree |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111241348A true CN111241348A (en) | 2020-06-05 |
CN111241348B CN111241348B (en) | 2024-03-01 |
Family
ID=70864914
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911410941.1A Active CN111241348B (en) | 2019-12-31 | 2019-12-31 | Method for dynamically adjusting Tree spacing based on Walker's Tree |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111241348B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113342907A (en) * | 2021-06-29 | 2021-09-03 | 积成电子股份有限公司 | Energy consumption information acquisition system distribution room topology portrait drawing method and system |
CN113496358A (en) * | 2021-07-13 | 2021-10-12 | 大唐互联科技(武汉)有限公司 | Index decomposition tree layout algorithm based on intelligent performance operation platform |
CN115166186A (en) * | 2022-08-08 | 2022-10-11 | 广东长天思源环保科技股份有限公司 | Online automatic monitoring system for water quality of water inlet of sewage treatment enterprise |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6978271B1 (en) * | 2000-10-31 | 2005-12-20 | Unisys Corporation | Mechanism for continuable calls to partially traverse a dynamic general tree |
CN102413509A (en) * | 2011-11-09 | 2012-04-11 | 中国科学院上海微***与信息技术研究所 | Construction method of time-delay-constrained energy consumption balance data acquisition tree in WSN (Wireless Sensor Network) |
CN104915952A (en) * | 2015-05-15 | 2015-09-16 | 中国科学院上海微***与信息技术研究所 | Method for extracting local salient objects in depth image based on multi-way tree |
CN106059861A (en) * | 2016-07-26 | 2016-10-26 | 河南工程学院 | Distributed construction system and method for internet of things minimum dynamic aggregation tree |
US20170068893A1 (en) * | 2015-09-03 | 2017-03-09 | Ali Abbas | System, Method and Software for Representing Decision Trees |
US20170091241A1 (en) * | 2015-09-29 | 2017-03-30 | Vmware, Inc. | Leveraging hierarchy in a tree data structure to dynamically allocate keys |
CN113326403A (en) * | 2021-06-16 | 2021-08-31 | 北京百度网讯科技有限公司 | Flowchart rendering method and device, electronic equipment and medium |
-
2019
- 2019-12-31 CN CN201911410941.1A patent/CN111241348B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6978271B1 (en) * | 2000-10-31 | 2005-12-20 | Unisys Corporation | Mechanism for continuable calls to partially traverse a dynamic general tree |
CN102413509A (en) * | 2011-11-09 | 2012-04-11 | 中国科学院上海微***与信息技术研究所 | Construction method of time-delay-constrained energy consumption balance data acquisition tree in WSN (Wireless Sensor Network) |
CN104915952A (en) * | 2015-05-15 | 2015-09-16 | 中国科学院上海微***与信息技术研究所 | Method for extracting local salient objects in depth image based on multi-way tree |
US20170068893A1 (en) * | 2015-09-03 | 2017-03-09 | Ali Abbas | System, Method and Software for Representing Decision Trees |
US20170091241A1 (en) * | 2015-09-29 | 2017-03-30 | Vmware, Inc. | Leveraging hierarchy in a tree data structure to dynamically allocate keys |
CN106059861A (en) * | 2016-07-26 | 2016-10-26 | 河南工程学院 | Distributed construction system and method for internet of things minimum dynamic aggregation tree |
CN113326403A (en) * | 2021-06-16 | 2021-08-31 | 北京百度网讯科技有限公司 | Flowchart rendering method and device, electronic equipment and medium |
Non-Patent Citations (2)
Title |
---|
孔涛;熊毅;: "故障树自动生成***的树图布局算法研究", 中国安全科学学报, no. 05 * |
陈大岳;章复熹;: "关于随机树上λ-随机游动速度的一个注记", 中国科学:数学, no. 05 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113342907A (en) * | 2021-06-29 | 2021-09-03 | 积成电子股份有限公司 | Energy consumption information acquisition system distribution room topology portrait drawing method and system |
CN113342907B (en) * | 2021-06-29 | 2023-02-21 | 积成电子股份有限公司 | Energy consumption information acquisition system distribution room topology portrait drawing method and system |
CN113496358A (en) * | 2021-07-13 | 2021-10-12 | 大唐互联科技(武汉)有限公司 | Index decomposition tree layout algorithm based on intelligent performance operation platform |
CN115166186A (en) * | 2022-08-08 | 2022-10-11 | 广东长天思源环保科技股份有限公司 | Online automatic monitoring system for water quality of water inlet of sewage treatment enterprise |
Also Published As
Publication number | Publication date |
---|---|
CN111241348B (en) | 2024-03-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111241348A (en) | Method for dynamically adjusting Tree spacing based on Walker's Tree | |
CN106294664B (en) | Method and device for generating thinking guide graph | |
CN101877138B (en) | Animation planning method and device of dynamic diagram | |
CN109146946B (en) | Image non-local stereo matching method | |
CN111695223B (en) | Network topology layout method and system | |
US8237716B2 (en) | Algorithm for drawing directed acyclic graphs | |
US20240220517A1 (en) | Identifying and graphically representing multiple parent nodes of a child node | |
CN106484754A (en) | Based on hierarchical data and the knowledge forest layout method of diagram data visualization technique | |
CN104408754B (en) | A kind of icon synthetic method | |
KR20080068869A (en) | Smart copy/paste of graphical nodes | |
US11392627B2 (en) | Identifying missing nodes within a graphically represented family | |
CN111524445B (en) | Map generation method and device, electronic equipment and readable storage medium | |
CN110610045A (en) | Intelligent cloud processing system and method for generating three views by selecting cabinet and wardrobe | |
US20220083574A1 (en) | Graphically Representing Related Record Families Using a Phantom Parent Node | |
CN111241646A (en) | Layout method of power grid equipment and computer readable storage medium | |
CN107491305A (en) | Data analysis and visible processing method, device | |
CN107301263A (en) | A kind of river network development process formula generation method based on single image | |
Muelder et al. | A treemap based method for rapid layout of large graphs | |
CN109685897B (en) | House type drawing method for drawing door and window opening by one-step dragging | |
CN112383422B (en) | Network topology optimization method for accelerating convergence speed of consistency distributed algorithm | |
CN113536663B (en) | Graph visualization method and system based on ring constraint and stress model | |
CN112000662B (en) | Hyperbolic tree-based family tree data visualization method | |
CN114049387B (en) | Tree skeleton extraction method based on 3D point cloud | |
CN111897895A (en) | Cooperative shifting method for solving conflict of road internal space considering curve characteristics | |
CN111260755B (en) | Digital tie-dyeing pattern generation method based on deep learning and digital image processing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |