Help with an algorithm wanted

William Park opengeometry at NOSPAM.yahoo.ca
Thu Jun 27 20:24:05 CEST 2002


Russell E. Owen <rowen at cesmail.net> wrote:
> In article <mailman.1025125654.6891.python-list at python.org>, William Park
> <opengeometry at yahoo.ca> wrote:
>>If pairing (ie. mapping between 2 objects) occurs randomly, then it's
>>virtually impossible, because you don't know which direction to go from any
>>one object.  It would be travelling from city to city, without knowing
>>which state or county.
> 
> Fortunately the pairings (conversion functions) are completely fixed. So  
> the graph never varies, and it even has a fairly simple shape (basically 
> a fork with 3 tines and a long handle, if that makes any sense).
> 
> The problem is that the graph has 10 nodes. Rather than hand code 10 
> different objects, I'm trying to create a factory that will generate the 
> required object based on which node (data representation) is a given 
> from which the others are derived.

In your previous example, C is the central "hub" for A, B, and D.  If you
have
    hub = {'A': 'C', 'B': 'C', 'D': 'C'}
then, you can find the node to which A, B, and D are attached, ie.
    >>> hub['D']
    'C'

Can you organize other objects around hubs?  After that, organize the hubs
into central hub of their own?  If so, then the traversal will be much
easier.

It's difficult to get our teeth into without knowing what the big picture
looks like... :-)

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin



More information about the Python-list mailing list