home » zplus/dokk.org.git
Author zPlus <zplus@peers.community> 2022-08-27 14:26:31
Committer zPlus <zplus@peers.community> 2022-08-27 14:26:31
Commit 2a9ed72 (patch)
Tree b6211de
Parent(s)

Remove unused networkx code.


commits diff: 300f674..2a9ed72
1 file changed, 3 insertions, 24 deletionsdownload


Diffstat
-rwxr-xr-x mknodes.py 27

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+3/-24 M   mknodes.py
index e3d4d71..712e478
old size: 2K - new size: 1K
@@ -2,20 +2,15 @@
2 2
3 3 """
4 4 This script creates the data.js file containing the list of nodes end edges for
5 - the vis.js graph.
5 + the vis.js graph. Just place data.js in the same folder with index.html.
6 6 """
7 7
8 8 import json
9 - import networkx
10 - import matplotlib.pyplot as plt
11 9 from pathlib import Path
12 10
13 -
14 - G = networkx.nx.Graph()
15 -
16 -
17 11 data = '../dokk/data'
18 - edge_properties = [ 'comics_cartoon', 'comics_author', 'ttrpg_character' ]
12 + edge_properties = [ 'comics_cartoon', 'comics_author', 'ttrpg_character',
13 + 'community_project' ]
19 14
20 15 nodes = []
21 16 edges = []
@@ -24,8 +19,6 @@ for path in Path(data).glob('**/*.json',):
24 19 with open(path, 'r') as f:
25 20 n = json.loads(f.read())
26 21
27 - G.add_node(n['node_id'])
28 -
29 22 nodes.append({
30 23 'title': n['node_name'] + ('\n' + n['node_description'] if 'node_description' in n else ''),
31 24 #'color': { 'background': '', 'border': ''},
@@ -41,8 +34,6 @@ for path in Path(data).glob('**/*.json',):
41 34 n[p] = [ n[p] ]
42 35
43 36 for target in n[p]:
44 - G.add_edge(n['node_id'], target)
45 -
46 37 edges.append({
47 38 'title': p,
48 39 'from': n['node_id'],
@@ -50,17 +41,5 @@ for path in Path(data).glob('**/*.json',):
50 41 'to': target,
51 42 })
52 43
53 - """
54 - pos = networkx.nx.spring_layout(G, k=1, iterations=200, scale=1000)
55 -
56 - for n in nodes:
57 - n['x'] = pos[n['id']][0]
58 - n['y'] = pos[n['id']][1]
59 -
60 - networkx.nx.set_node_attributes(G, pos, 'pos')
61 - networkx.nx.draw(G, pos=pos)
62 - plt.show()
63 - """
64 -
65 44 with open('data.js', 'w') as f:
66 45 f.write('var nodes={};\nvar edges={}'.format(json.dumps(nodes), json.dumps(edges)))