remove_random_edges#
- graph_tool.generation.remove_random_edges(g, M, weight=None, counts=True)[source]#
Remove edges from the graph, chosen uniformly at random.
- Parameters:
- g
Graph
Graph to be modified.
- M
int
Number of edges to be removed.
- weight
EdgePropertyMap
, optional (default:None
) Integer edge multipliciites or edge removal probabilities. If supplied, and
counts == True
this will be decremented for edges removed.- counts
bool
, optional (default:True
) If
True
, the values given byweight
are assumed to be integer edge multiplicities. Otherwise, they will be only considered to be proportional to the probability of an edge being removed.
- g
See also
add_random_edges
add random edges to the graph
Notes
This algorithm runs in time \(O(E\left<k\right>)\) if
weight is None
, otherwise \(O(E + \left<k\right>M\log E)\).Note
The complexity can be improved to \(O(E)\) and \(O(E + M\log E)\), respectively, if fast edge removal is activated via
set_fast_edge_removal()
prior to running this function.Examples
>>> g = gt.lattice([100, 100]) >>> gt.remove_random_edges(g, 10000) >>> print(gt.label_components(g)[1].max()) 3371