Fix rendering of outgoing links on graph.
See: http://127.0.0.1:8000/notes/343fe43b-f687-4f83-8171-c966a6887898.node.html#343fe43b-f687-4f83-8171-c966a6887898
This commit is contained in:
parent
da20c14ae7
commit
539240079f
@ -4,7 +4,7 @@ import copy
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
# TODO: Properly render outgouing links
|
||||
|
||||
@ops_cache.cache
|
||||
def gen(headline_id, graph):
|
||||
reference_node = headline_id
|
||||
@ -17,6 +17,7 @@ def gen(headline_id, graph):
|
||||
in_emacs_tree = {
|
||||
reference_node: set(),
|
||||
}
|
||||
linked_from_internal = set()
|
||||
|
||||
while new_nodes:
|
||||
new_nodes = False
|
||||
@ -46,7 +47,11 @@ def gen(headline_id, graph):
|
||||
l for l in v["links"]
|
||||
if l.get('relation') != 'in'
|
||||
]
|
||||
|
||||
for l in v['links']:
|
||||
lt = l['target']
|
||||
if lt.startswith("id:"):
|
||||
lt = lt[3:]
|
||||
linked_from_internal.add(lt)
|
||||
|
||||
removed.add(k)
|
||||
new_nodes = True
|
||||
@ -58,10 +63,15 @@ def gen(headline_id, graph):
|
||||
|
||||
# One more round for the rest, not requiring "in"
|
||||
for k, v in g.items():
|
||||
backlinked = False
|
||||
for link in v["links"]:
|
||||
if link["target"].startswith("id:"):
|
||||
link["target"] = link["target"][3:]
|
||||
if link['target'] in in_emacs:
|
||||
centered_graph[k] = v
|
||||
backlinked = True
|
||||
removed.add(k)
|
||||
if not backlinked and (k in linked_from_internal):
|
||||
centered_graph[k] = v
|
||||
removed.add(k)
|
||||
|
||||
@ -84,12 +94,14 @@ def gen(headline_id, graph):
|
||||
# print("T: {}".format(in_emacs_tree), file=sys.stderr)
|
||||
for k in in_emacs_tree[node_id]:
|
||||
v = g[k]
|
||||
print("_" + k.replace("-", "_") + "[label=\"" + v["title"].replace("\"", "'") + "\", URL=\"" + k + ".node.html\"];", file=f)
|
||||
|
||||
if k in in_emacs_tree:
|
||||
draw_subgraph(k)
|
||||
else:
|
||||
print(" _" + k.replace("-", "_") + "[label=\"" + v["title"].replace("\"", "'") + "\", URL=\"" + k + ".node.html\"];", file=f)
|
||||
|
||||
f.write("\n}")
|
||||
|
||||
f.write("\n}\n")
|
||||
|
||||
draw_subgraph(reference_node)
|
||||
|
||||
@ -98,6 +110,10 @@ def gen(headline_id, graph):
|
||||
print("_" + k.replace("-", "_") + "[label=\"" + v["title"].replace("\"", "'") + "\", URL=\"" + k + ".node.html\"];", file=f)
|
||||
|
||||
for k, v in g.items():
|
||||
link_src = '_' + k.replace("-", "_")
|
||||
if k in in_emacs_tree:
|
||||
link_src = 'cluster_{}'.format(k.replace("-", "_"))
|
||||
|
||||
for link in v["links"]:
|
||||
if link["target"].startswith("id:"):
|
||||
link["target"] = link["target"][3:]
|
||||
@ -112,7 +128,7 @@ def gen(headline_id, graph):
|
||||
t = 'cluster_{}'.format(link['target'].replace("-", "_"))
|
||||
else:
|
||||
t = "_" + link["target"].replace("-", "_")
|
||||
print("_" + k.replace("-", "_") + "->" + t, file=f)
|
||||
print(link_src + "->" + t, file=f)
|
||||
|
||||
f.write('}\n')
|
||||
f.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user