Changed link connection to middle node in block
Hidden node was removed from a block to reduce empty space. Link from previous level is connected to the node in the middle (or the first of two middle nodes when even number of nodes). Added ranksep in config to increase vertical space.
This commit is contained in:
parent
93e2554457
commit
bf788ca544
@ -1,4 +1,5 @@
|
||||
|
||||
import math
|
||||
import os
|
||||
import uuid
|
||||
|
||||
@ -109,25 +110,31 @@ class Graph:
|
||||
"label": block.get("label", ""),
|
||||
"texts": []
|
||||
}
|
||||
hidden_node_id = get_id()
|
||||
self.nodes.append({"id": hidden_node_id, "text": "", "hidden": True})
|
||||
new_block["texts"].append(hidden_node_id)
|
||||
|
||||
links = block.get("links", [])
|
||||
for link in links:
|
||||
if link in linker:
|
||||
self.links.append({"from": linker[link], "to": hidden_node_id, "head": block_id, "hidden": False})
|
||||
del linker[link]
|
||||
|
||||
for text in block.get("texts", []):
|
||||
#prev_node_id = ""
|
||||
texts_in_block = block.get("texts", [])
|
||||
for i, text in enumerate(texts_in_block):
|
||||
node_id = get_id()
|
||||
|
||||
# Link to middle node
|
||||
if i == math.ceil(len(texts_in_block) / 2) - 1:
|
||||
for link in block.get("links", []):
|
||||
if link in linker:
|
||||
self.links.append({"from": linker[link], "to": node_id, "head": block_id, "hidden": False})
|
||||
del linker[link]
|
||||
|
||||
self.nodes.append({"id": node_id, "text": text.get("text", ""), "hidden": False})
|
||||
self.links.append({"from": hidden_node_id, "to": node_id, "head": "", "hidden": True})
|
||||
|
||||
# Chain nodes in block
|
||||
#if prev_node_id:
|
||||
# self.links.append({"from": prev_node_id, "to": node_id, "head": "", "hidden": True})
|
||||
|
||||
new_block["texts"].append(node_id)
|
||||
|
||||
links = text.get("links", [])
|
||||
for link in links:
|
||||
for link in text.get("links", []):
|
||||
linker[link] = node_id
|
||||
|
||||
#prev_node_id = node_id
|
||||
|
||||
self.blocks.append(new_block)
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
dot:
|
||||
graph: |
|
||||
graph [splines=ortho, nodesep=0.2]
|
||||
graph [splines=ortho, nodesep=0.2, ranksep="0.5 equally"]
|
||||
//node [color=white]
|
||||
//edge [headport=n, tailport=s]
|
||||
compound=true
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 138 KiB |
Loading…
x
Reference in New Issue
Block a user