JD:
> Thanks,
> This one really works.

Note that you can save some RAM (almost half) creating a directed
graph, because later the connectedComponents() manages the arcs as
undirected anyway:

>>> from graph import Graph
>>> g = Graph()
>>> data = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['a', 'g'], ['e', 'k'], ['c', 
>>> 'u'], ['b', 'p']]
>>> g.addArcs(data)
>>> g.connectedComponents()
[['a', 'b', 'g', 'p'], ['c', 'u', 'd'], ['e', 'k', 'f']]

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to