^digraph_print
This commit is contained in:
parent
b94a746447
commit
1cd1742344
12
srcxray.py
12
srcxray.py
|
@ -468,8 +468,9 @@ def digraph_tree(dg, starts=None, black_list=black_list):
|
||||||
|
|
||||||
def digraph_print(dg, starts=None, dst_fn=None, sort=False):
|
def digraph_print(dg, starts=None, dst_fn=None, sort=False):
|
||||||
dst = open(dst_fn, 'w') if dst_fn else None
|
dst = open(dst_fn, 'w') if dst_fn else None
|
||||||
|
printed = set()
|
||||||
|
|
||||||
def digraph_print_sub(path='', node=None, printed=None, level=0):
|
def digraph_print_sub(path='', node=None, level=0):
|
||||||
if node in black_list:
|
if node in black_list:
|
||||||
return
|
return
|
||||||
if node in printed:
|
if node in printed:
|
||||||
|
@ -493,9 +494,8 @@ def digraph_print(dg, starts=None, dst_fn=None, sort=False):
|
||||||
if o in passed:
|
if o in passed:
|
||||||
continue
|
continue
|
||||||
passed.add(o)
|
passed.add(o)
|
||||||
digraph_print_sub(path + ' ' + str(node), o, printed, level + 1)
|
digraph_print_sub(path + ' ' + str(node), o, level + 1)
|
||||||
|
|
||||||
printed = set()
|
|
||||||
if not starts:
|
if not starts:
|
||||||
starts = {}
|
starts = {}
|
||||||
for i in [n for (n, d) in dg.in_degree if not d]:
|
for i in [n for (n, d) in dg.in_degree if not d]:
|
||||||
|
@ -511,11 +511,11 @@ def digraph_print(dg, starts=None, dst_fn=None, sort=False):
|
||||||
continue
|
continue
|
||||||
passed.add(o)
|
passed.add(o)
|
||||||
if o in dg:
|
if o in dg:
|
||||||
digraph_print_sub('', o, printed)
|
digraph_print_sub('', o)
|
||||||
# not yet printed rest:
|
# not yet printed rest:
|
||||||
for o in dg.nodes():
|
for o in dg.nodes():
|
||||||
if o not in printed:
|
if o not in printed:
|
||||||
digraph_print_sub('', o, printed)
|
digraph_print_sub('', o)
|
||||||
if dst_fn:
|
if dst_fn:
|
||||||
print(dst_fn)
|
print(dst_fn)
|
||||||
dst.close()
|
dst.close()
|
||||||
|
@ -914,7 +914,7 @@ class _unittest_autotest(unittest.TestCase):
|
||||||
os.chdir('..')
|
os.chdir('..')
|
||||||
self.assertTrue(syscalls().number_of_edges() > 400)
|
self.assertTrue(syscalls().number_of_edges() > 400)
|
||||||
# digraph_print:
|
# digraph_print:
|
||||||
self.assertEqual("\thandle_initrd ^", popen("srcxray.py import_cflow init/do_mounts_initrd.c")[-1])
|
self.assertEqual("\t\tmount_initrd ^", popen("srcxray.py import_cflow init/do_mounts_initrd.c")[-1])
|
||||||
self.assertEqual("\t\t4", popen('srcxray.py "nx.DiGraph([{1,2},{2,3},{2,4}])"')[-1])
|
self.assertEqual("\t\t4", popen('srcxray.py "nx.DiGraph([{1,2},{2,3},{2,4}])"')[-1])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue