mosdef-hub / mbuild

A hierarchical, component based molecule builder
https://mbuild.mosdef.org
Other
171 stars 80 forks source link

BondGraph.connected_components can hit the recursion limit #205

Closed ctk3b closed 7 years ago

ctk3b commented 7 years ago

Appears to happen stochastically on some of the Travis tests and according to @summeraz happens regularly with larger systems.

Might need to reformulate this as a non-recursive function: https://github.com/iModels/mbuild/blob/master/mbuild/bond_graph.py#L101

summeraz commented 7 years ago

As a more concrete example, the following code appears to always produce this error:

import mbuild as mb
from mbuild.lib.bulk_materials import AmorphousSilica
amorphous_surface = mb.SilicaInterface(bulk_silica=AmorphousSilica(),tile_x=3,tile_y=3)
ctk3b commented 7 years ago

I think just mimicking this should do the trick. Wanna give it a whack?

https://github.com/networkx/networkx/blob/cc5a81a1d437e490efaf23e4fb82ab49e05ca392/networkx/algorithms/components/connected.py#L27

https://github.com/networkx/networkx/blob/cc5a81a1d437e490efaf23e4fb82ab49e05ca392/networkx/algorithms/components/connected.py#L234

ctk3b commented 7 years ago

http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/

summeraz commented 7 years ago

Yeah, that should work. I'll give it a shot

ctk3b commented 7 years ago

Resolved by #206