-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGrapher.py
41 lines (32 loc) · 1.04 KB
/
Grapher.py
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
35
36
37
38
39
40
41
#!/usr/bin/env python
import os
import networkx as nx
__author__ = "Alex Hoffman"
__copyright__ = "Copyright 2019, Alex Hoffman"
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Alex Hoffman"
__email__ = "[email protected]"
__status__ = "Beta"
class Grapher:
""" A simple object to wrap a process tree generated by the energy debugger tool into a networkx A graph.
"""
def __init__(self, process_tree, subdir):
self.subdir = subdir
self.pt = process_tree
def draw_graph(self):
a_graph = nx.nx_agraph.to_agraph(self.pt.graph)
a_graph.graph_attr["splines"] = "polyline"
a_graph.graph_attr["packmode"] = "node"
a_graph.graph_attr["margin"] = 2
file_path = "results/"
if self.subdir:
file_path += self.subdir + "/"
a_graph.draw(
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
file_path + self.pt.pidtracer.name,
) + ".xdot",
format="xdot",
prog="dot",
)