[gjs: 8/11] heapgraph: Always keep "interesting" labels in graph



commit a172af1cc29390fa6a74f0fa9036f8a13cd17f2a
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Aug 10 13:55:13 2019 -0700

    heapgraph: Always keep "interesting" labels in graph
    
    If you specify an edge target, then it may happen that the edge isn't
    actually printed in the graph. Since the search only prints at most one
    reason why a node is reachable, then for example if the edge's source
    and destination are rooted then the edge won't appear.
    
    In the console output tree graph we can't handle multiple edges pointing
    to a node, but a dot graph can handle that just fine. So we add these
    extra "interesting" edges at the end of the code that prints out the dot
    graph.

 tools/heapdot.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/tools/heapdot.py b/tools/heapdot.py
index 69f8194e..660e2401 100644
--- a/tools/heapdot.py
+++ b/tools/heapdot.py
@@ -189,5 +189,15 @@ def output_dot_file(args, graph, targs, fname):
 
             outf.write('  q{0} -> q{1} [label="{2}", color={3}, style="{4}"];\n'.format(origin, destination, 
label, color, style))
 
+    # Extra edges, marked as "interesting" via a command line argument
+    if args.edge_targets:
+        for origin, paths in graph.edge_labels.items():
+            for destination, labels in paths.items():
+                if destination in edges.get(origin, set()):
+                    continue  # already printed
+                for label in labels:
+                    if label in args.edge_targets:
+                        outf.write('  q{0} -> q{1} [label="{2}", color=black, 
style="solid"];\n'.format(origin, destination, label))
+
     outf.write('}\n')
     outf.close()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]