forked from OpenSDV/Linux_Kernel_map4vehicle
reduce_graph
This commit is contained in:
parent
c0f41543d3
commit
e2784f087a
15
srcxray.py
15
srcxray.py
|
@ -245,6 +245,17 @@ def my_graph(name=None):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
|
def reduce_graph(g):
|
||||||
|
print(type(g))
|
||||||
|
rm = set()
|
||||||
|
for e in g:
|
||||||
|
if not g.out_degree(e):
|
||||||
|
rm.add(e)
|
||||||
|
print(rm)
|
||||||
|
g.remove_nodes_from(rm)
|
||||||
|
return g
|
||||||
|
|
||||||
|
|
||||||
def syscalls():
|
def syscalls():
|
||||||
sc = my_graph('syscalls')
|
sc = my_graph('syscalls')
|
||||||
scd = 'SYSCALL_DEFINE.list'
|
scd = 'SYSCALL_DEFINE.list'
|
||||||
|
@ -293,11 +304,11 @@ def digraph_print(dg):
|
||||||
def digraph_print_sub(node=None, printed=None, level=0):
|
def digraph_print_sub(node=None, printed=None, level=0):
|
||||||
outs = [_ for _ in dg.successors(node)]
|
outs = [_ for _ in dg.successors(node)]
|
||||||
if node in printed:
|
if node in printed:
|
||||||
print_limited(level*'\t' + node + ' ^')
|
print_limited(level*'\t' + str(node) + ' ^')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
s = ' ...' if level > level_limit - 2 and outs else ''
|
s = ' ...' if level > level_limit - 2 and outs else ''
|
||||||
print_limited(level*'\t' + node + s)
|
print_limited(level*'\t' + str(node) + s)
|
||||||
printed.add(node)
|
printed.add(node)
|
||||||
if level > level_limit - 2:
|
if level > level_limit - 2:
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in New Issue