-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgenerateGraph.py
More file actions
34 lines (22 loc) · 872 Bytes
/
generateGraph.py
File metadata and controls
34 lines (22 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pyyed
import sys
import os
sys.path.append(os.path.join(os.getcwd(),'PandaVis'))# to make the bakeReader imports work
from PandaVis.bakeReader.bakeReader import BakeReader
reader = BakeReader('/media/D/Data/HTM/htm-2d-object-modeling/python/bakedDatabase/pandaVis.db')
reader.OpenDatabase()
regions, links = reader.LoadStructure()
g = pyyed.Graph()
for regName, regType in regions.items():
g.add_node(regName, shape="roundrectangle")
for linkId, linkData in links.items():
g.add_edge(linkData[0], linkData[2], label=linkData[1]+' -> '+ linkData[3], width="3.0", color="#0000FF",
)
print(g.get_graph())
# To write to file:
with open('test_graph.graphml', 'w') as fp:
fp.write(g.get_graph())
# Or:
g.write_graph('example.graphml')
# Or, to pretty-print with whitespace:
g.write_graph('pretty_example.graphml', pretty_print=True)