3 # Filter out arcs in a dotty graph that are at or below a certain
4 # node. This is useful for visualising parts of the dependency graph.
12 if len(sys
.argv
) != 2:
13 print('Usage: depfilter.py NODE')
20 lines
= sys
.stdin
.readlines()
24 for arc
in lines
[1:-1]:
25 match
= re
.search('"(.*)" -> "(.*)"', arc
)
26 n1
, n2
= match
.group(1), match
.group(2)
31 # Create subset of 'graph' rooted at 'top'
37 if node
in graph
and node
not in subgraph
:
38 subgraph
[node
] = graph
[node
]
47 print(lines
[0], end
=' ')
49 for key
, value
in subgraph
.items():
51 print('\t"%s" -> "%s"' % (key
, n
))
53 print(lines
[-1], end
=' ')