forked from OpenSDV/Linux_Kernel_map4vehicle
*reduce_graph
This commit is contained in:
parent
686b1f9553
commit
78920c9b51
|
@ -281,12 +281,13 @@ def my_graph(name=None):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
def reduce_graph(g):
|
def reduce_graph(g, m=None):
|
||||||
rm = set()
|
rm = set()
|
||||||
for e in g:
|
m = g.number_of_nodes() if not m else m
|
||||||
if not g.out_degree(e):
|
print(g.number_of_edges())
|
||||||
rm.add(e)
|
rm = [n for (n, d) in g.out_degree if not d and g.in_degree(n) <= m]
|
||||||
g.remove_nodes_from(rm)
|
g.remove_nodes_from(rm)
|
||||||
|
print(g.number_of_edges())
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue