Finding all cycles within an undirected graph (disappearedng)

disappearedng disappearedng at gmail.com
Wed Jul 22 10:16:31 EDT 2009


Actually, I have realized that using the bit vector XOR method by
http://www.me.utexas.edu/~bard/IP/Handouts/cycles.pdf gives some
possibility of doing so. However this method is still experimental and
doesn't really have a definitive end to the algorithm (the base number
of vectors can change).

Any ideas anyone?

On Wed, Jul 22, 2009 at 9:12 PM, <python-list-request at python.org> wrote:
> Send Python-list mailing list submissions to
>        python-list at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>        python-list-request at python.org
>
> You can reach the person managing the list at
>        python-list-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Finding all cycles within an undirected graph (disappearedng)
>   2. Re: Re: Changing the private variables content (Xavier Ho)
>   3. Python-URL! - weekly Python news and links (Jul 22)
>      (Gabriel Genellina)
>   4. Re: Multiple versions of python (Dave Angel)
>   5. Re: Changing the private variables content (MRAB)
>
>
> ---------- Forwarded message ----------
> From: disappearedng <disappearedng at gmail.com>
> To: python-list at python.org
> Date: Wed, 22 Jul 2009 21:04:18 +0800
> Subject: Finding all cycles within an undirected graph
> Hey everyone,
> I am interested to find out all the cycles within an undirected graph.
> I don't have a particular implementation of nodes and vertices yet, so
> would someone kindly point out a good graph library for this ( I
> looked at pygraph and python-graph, but not really satisfied ), in
> addition to good algorithm for solving this issue.
>
>
>
> ---------- Forwarded message ----------
> From: Xavier Ho <contact at xavierho.com>
> To: python-list at python.org
> Date: Wed, 22 Jul 2009 23:06:22 +1000
> Subject: Re: Re: Changing the private variables content
> Got it:
>
> exec('self.' + attr + '=\'' + val + '\'')
>
> That worked. I think it'll do what you want now ;)
>
> Ching-Yun "Xavier" Ho, Technical Artist
>
> Contact Information
> Mobile: (+61) 04 3335 4748
> Skype ID: SpaXe85
> Email: contact at xavierho.com
> Website: http://xavierho.com/
>
>
> ---------- Forwarded message ----------
> From: "Gabriel Genellina" <python-url at phaseit.net>
> To: python-list at python.org
> Date: Wed, 22 Jul 2009 12:48:25 +0000 (UTC)
> Subject: Python-URL! - weekly Python news and links (Jul 22)
> QOTW:  "If programming is symbol manipulation, then you should remember that
> the user interface is also symbol manipulation, and it is a MUCH harder
> problem than databases, sorting, searching, and all the other problems you
> learn about in academia. The user interface has to communicate over a rich
> but noisy channel using multiple under-specified protocols to a couple of
> pounds of meat which processes information using buggy heuristics evolved
> over millions of years to find the ripe fruit, avoid being eaten, and have
> sex. If you think getting XML was hard, that's *nothing* compared to user
> interfaces.
>
> The fact that even bad UIs work at all is a credit to the heuristics, bugs
> and all, in the meat." - Steven D'Aprano
>     http://groups.google.com/group/comp.lang.python/msg/8c65eacbd76e79cf
>
>
>    Invoke the same method over every object in a collection:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/8fd293a9b39c8733/
>
>    There is no 'xor' boolean operator, why? What should be its outcome?
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/16eec722310e75e8/
>
>    A thread-safe method to create unique identifiers (not necesarily
>    increasing integers):
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/dfe22a6446c057df/
>
>    Tim Chase tells us three ways to turn standard output into unbuffered mode:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/a65f71444bd4bb53/
>
>    How to receive data of unknown length using sockets:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/9e4a9f8b6e83320/
>
>    Override a method, but keeping the inherited docstring:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/1e4075ba10dcbdd9/
>
>    Limiting the execution time of a code fragment:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/734054de170e2904/
>
>    Sharing a big object between processes using the multiprocessing module:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/833d4988b7af6353/
>
>    Why aren't OrderedDicts [3.1] comparable using <, >, <=, >=?
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/c3c6f4fe7b6d487d/
>
>    So many ways to call a function - why is that? Beginners get confused:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/3fd57f5ee4850530/
>
>    The reasons to choose your favorite programming language (Python, I
>    presume!):
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/5d87008e328efcf9/
>
>    Tuples, lists, their differences and motivation:
>        http://groups.google.com/group/comp.lang.python/browse_thread/thread/cb0cf56c52321ccc/
>
>
> ========================================================================
> Everything Python-related you want is probably one or two clicks away in
> these pages:
>
>    Python.org's Python Language Website is the traditional
>    center of Pythonia
>        http://www.python.org
>    Notice especially the master FAQ
>        http://www.python.org/doc/FAQ.html
>
>    PythonWare complements the digest you're reading with the
>    marvelous daily python url
>         http://www.pythonware.com/daily
>
>    Just beginning with Python?  This page is a great place to start:
>        http://wiki.python.org/moin/BeginnersGuide/Programmers
>
>    The Python Papers aims to publish "the efforts of Python enthusiasts":
>        http://pythonpapers.org/
>    The Python Magazine is a technical monthly devoted to Python:
>        http://pythonmagazine.com
>
>    Readers have recommended the "Planet" sites:
>        http://planetpython.org
>        http://planet.python.org
>
>    comp.lang.python.announce announces new Python software.  Be
>    sure to scan this newsgroup weekly.
>        http://groups.google.com/group/comp.lang.python.announce/topics
>
>    Python411 indexes "podcasts ... to help people learn Python ..."
>    Updates appear more-than-weekly:
>        http://www.awaretek.com/python/index.html
>
>    The Python Package Index catalogues packages.
>        http://www.python.org/pypi/
>
>    Much of Python's real work takes place on Special-Interest Group
>    mailing lists
>        http://www.python.org/sigs/
>
>    Python Success Stories--from air-traffic control to on-line
>    match-making--can inspire you or decision-makers to whom you're
>    subject with a vision of what the language makes practical.
>        http://www.pythonology.com/success
>
>    The Python Software Foundation (PSF) has replaced the Python
>    Consortium as an independent nexus of activity.  It has official
>    responsibility for Python's development and maintenance.
>        http://www.python.org/psf/
>    Among the ways you can support PSF is with a donation.
>        http://www.python.org/psf/donations/
>
>    The Summary of Python Tracker Issues is an automatically generated
>    report summarizing new bugs, closed ones, and patch submissions.
>        http://search.gmane.org/?author=status%40bugs.python.org&group=gmane.comp.python.devel&sort=date
>
>    Although unmaintained since 2002, the Cetus collection of Python
>    hyperlinks retains a few gems.
>        http://www.cetus-links.org/oo_python.html
>
>    Python FAQTS
>        http://python.faqts.com/
>
>    The Cookbook is a collaborative effort to capture useful and
>    interesting recipes.
>        http://code.activestate.com/recipes/langs/python/
>
>    Many Python conferences around the world are in preparation.
>    Watch this space for links to them.
>
>    Among several Python-oriented RSS/RDF feeds available, see:
>        http://www.python.org/channews.rdf
>    For more, see:
>        http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
>    The old Python "To-Do List" now lives principally in a
>    SourceForge reincarnation.
>        http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse
>        http://www.python.org/dev/peps/pep-0042/
>
>    del.icio.us presents an intriguing approach to reference commentary.
>    It already aggregates quite a bit of Python intelligence.
>        http://del.icio.us/tag/python
>
>    Enjoy the *Python Magazine*.
>        http://pymag.phparch.com/
>
>    *Py: the Journal of the Python Language*
>        http://www.pyzine.com
>
>    Dr.Dobb's Portal is another source of Python news and articles:
>        http://www.ddj.com/TechSearch/searchResults.jhtml?queryText=python
>    and Python articles regularly appear at IBM DeveloperWorks:
>        http://www.ibm.com/developerworks/search/searchResults.jsp?searchSite=dW&searchScope=dW&encodedQuery=python&rankprofile=8
>
> Previous - (U)se the (R)esource, (L)uke! - messages are listed here:
>  http://search.gmane.org/?query=python+URL+weekly+news+links&group=gmane.comp.python.general&sort=date
>  http://groups.google.com/groups/search?q=Python-URL!+group%3Acomp.lang.python&start=0&scoring=d&
>  http://lwn.net/Search/DoSearch?words=python-url&ctype3=yes&cat_25=yes
>
> There is *not* an RSS for "Python-URL!"--at least not yet.  Arguments
> for and against are occasionally entertained.
>
>
> Suggestions/corrections for next week's posting are always welcome.
> E-mail to <Python-URL at phaseit.net> should get through.
>
> To receive a new issue of this posting in e-mail each Monday morning
> (approximately), ask <claird at phaseit.net> to subscribe.  Mention
> "Python-URL!".  Write to the same address to unsubscribe.
>
>
> -- The Python-URL! Team--
>
> Phaseit, Inc. (http://phaseit.net) is pleased to participate in and
> sponsor the "Python-URL!" project.  Watch this space for upcoming
> news about posting archives.
>
>
>
> ---------- Forwarded message ----------
> From: Dave Angel <davea at ieee.org>
> To: CCW <c.c.wood at gmail.com>
> Date: Wed, 22 Jul 2009 09:11:26 -0400
> Subject: Re: Multiple versions of python
> CCW wrote:
>>
>> On 21 July, 15:19, Dave Angel <da... at dejaviewphoto.com> wrote:
>>
>>>
>>> ChrisW wrote:
>>>
>>>>
>>>> Hi,
>>>>      I have installed 2 versions of python on my Windows XP computer - I
>>>> originally had 3.0.1, but then found that the MySQL module only
>>>> supported 2.*, so I've now installed that.  I have found that if I
>>>> change the Windows Environment Variable path, then I can change the
>>>> version of python called when I type 'python' into a command line.
>>>> However, I'd like to be able to choose which version I use.  I know
>>>> that if I change C:\Python26\python.exe to
>>>> C:\Python26\python2.exe and C:\Python30\python.exe to C:
>>>> \Python26\python3.exe, then typing 'python2' or 'python3' will invoke
>>>> the correct interpreter.  However, is it safe just to rename the
>>>> executable files? Is there a more elegant way to achieve the same
>>>> task?
>>>>      Thanks,
>>>> Chris
>>>>
>>>
>>> The elegant way is to have a batch directory on your PATH ( I use  m:\t\bat )  and put your *.bat files there.   I do NOT put any python
>>> installations on the PATH.
>>>
>>> For example, I have a batch file called:     m:\t\bat\python26.bat
>>>
>>> c:\progfiles\python26\python.exe %*
>>>
>>> The %* syntax means pass all arguments through to the program.
>>>
>>> Once it all works, you can add an "@" in front of the c:   in order to
>>> suppress echoing the command.  At that point, it'll look and work the
>>> same way as what you did, but without modifying anything in the install
>>> directory.    (You may want  python26.bat, pythonw26.bat, python31.bat
>>> and pythonw31.bat)
>>>
>>> The other thing you may want to do in a batch file is to change the file
>>> associations so that you can run the .py file directly, without typing
>>> "python" or "pythonw" in front of it.
>>>
>>> The relevant Windows commands are:     assoc and ftype      And on a
>>> related note, you may want to edit the PATHEXT environment variable, to
>>> add .PY and .PYW
>>>
>>
>> Thanks for this - this way made a bit more sense to me.  I've now got
>> C:\commands with the 4 .bat files in, and C:\commands in my path.  It
>> all seems to work :) I think I've missed the point of the @ though -
>> it doesn't seem to make any difference..
>>
>> I'm also a bit confused with the associations - since I've got python
>> 2.6 and 3.1, surely the command I type (python26 or python31) is the
>> only way to force a script to be run using a specific interpreter at
>> runtime without having to change the .bat file every time I want to
>> run a script using 3.1 instead of 2.6?
>>
>>
>
> The @ symbol was used in older versions of CMD and COMMAND to suppress echoing of the command line.  I think if you're using XP or later, it doesn't matter.
>
> As for file associations, I don't know just what you already know about.  When you type    data.doc    at a command line, the system looks for the data file, then if it's found, it looks up the program associated with that extension.  On my machine, that's a particular version of Word for Windows.  Similarly, if I type    digest.py   and I'm in the directory containing that file, the system looks up my associations, and runs Python 2.6 on that file.  If I wanted it to run Python 3.1 on that file, I'd have to change the associations, temporarily.
>
> So, first approximation, it's a way to avoid having to type PYTHON each time I want to run a script, as long as I don't need any other arguments on the (implied) command line.  Further, the system will then look for digest.py everywhere on the PATH, so I don't even have to be in the same directory.  And that means I can be in the data directory that digest.py is going to work on.  Effectively, it raises digest.py to feeling like an executable, for most purposes.  In fact, I put all my scripts in a directory, along with other simple executables.   I use  m:\t\bin  for that purpose.
>
> These associations (to .py and .pyw) are established by the installer program for Python.  But when you had multiple installs, you could choose whether the second one installed overrides the first.  My point is that if you need to change them back and forth, you could use  assoc and ftype to do it.
>
> On my system:
>
> M:\LabOrders>assoc .py
> .py=Python.File
>
> M:\LabOrders>ftype Python.File
> Python.File="C:\PROGFI~1\ACTIVE~1\python.exe" "%1" %*
>
> M:\LabOrders>
>
>
> So my .py files are associated with the 2.6.2 version of ActivePython installation.   Note the similarity of the ftype to your python26.bat file?
>
> One more little trick is that I could just type   digest    instead of    digest.py,   if I have added the .py and .pyw extensions to my   PATHEXT environment variable.    So my PATHEXT looks like:
>  PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PY;.PYW
>
>
>
> Note that the association changes made by  assoc and ftype are global.  They apply to all cmd.exe windows, even those already running, and they survive a reboot.  But when you set environment variables like PATHEXT,  you can choose to do it in a single window (with SET), or globally (using control-panel).
>
> If I found myself switching often, I'd make separate ftype entries for each interpreter, something like
>  Python.File26="C:\PROGFI~1\ACTIVE~1\python.exe" "%1" %*
>  Python.File31="C:\PROGFI~1\.....
> and just change assoc .py  to point at the one I needed today.
>
> As it is, I'm content leaving the associations pointing at 2.6, and explicitly entering PYTHON31 in front of any script name I want to run on that interpreter.
>
> DaveA
>
>
>
>
> ---------- Forwarded message ----------
> From: MRAB <python at mrabarnett.plus.com>
> To: python-list at python.org
> Date: Wed, 22 Jul 2009 14:12:18 +0100
> Subject: Re: Changing the private variables content
> Ryniek90 wrote:
>>>
>>> ------------------------------------------------------------------------
>>>
>>> Temat:
>>> Re: Changing the private variables content
>>> Od:
>>> Gary Herron <gherron at islandtraining.com>
>>> Data:
>>> Tue, 21 Jul 2009 14:14:44 -0700
>>> Do:
>>> Ryniek90 <ryniek90 at gmail.com>
>>>
>>> Do:
>>> Ryniek90 <ryniek90 at gmail.com>
>>> Kopia:
>>> python-list at python.org
>>>
>>>
>>> Ryniek90 wrote:
>>>>
>>>> Hi.
>>>> I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have.
>>>> Maybe some example.
>>>> A class with private method and private variable:
>>>>
>>>> "
>>>> >>> class Secret(object):
>>>>   #
>>>>   def __init__(self):
>>>>       self._number = 1
>>>>   #
>>>>   def _secret(self):
>>>>       print self._number
>>>>   def showit(self):
>>>>       print "Secret number is:\n"
>>>>       self._secret()
>>>>
>>>> >>> sec = Secret()
>>>> >>> sec.showit()
>>>> Secret number is:
>>>>
>>>> 1
>>>> >>> sec._number
>>>> 1
>>>> >>> sec._number = 2
>>>> >>> sec._number
>>>> 2
>>>> >>> sec._number += 3
>>>> >>> sec._number
>>>> 5
>>>> >>>
>>>> "
>>>>
>>>> As You can see, i made class with private method and private variable inside __init__ constructor. I've changed also the variable value, but outside class.
>>>> I've got problem with changing some variable value _inside__my_ class, which i'm writing.
>>>
>>> Not sure this is what you are asking, but a method (which is how I interpret "_inside__my_ class") changes the value by normal assignment like this:
>>>
>>> class Secret(object):
>>>  ...
>>>  def SetNumber(self,value):
>>>   self._number = value
>>>
>>> Is that what you were asking?
>>>
>>>
>>> Gary Herron
>>>
>>>
>>>
>>>> I've searched over google, some tuts with topics about operations on private variables, but didn't found anything - only how to make them, but no how to assign new objects/override them with new content (and other advanced and helpful options).
>>>>
>>>> If someone could help me, it would be great.
>>>>
>>>> Thanks.
>>>
>>>
>>
>>
>> Thanks for hint, but looks like i can't do what i want.
>>
>> Maybe i show You my class:
>>
>> "
>>
>> class ModPrint(object):
>>     u"""
>>   This will be the doc.
>>   """
>>     def __init__(self):
>>             #Assign the Python installation directory - sys.exec_prefix - to variable
>>       self._default_search_path=sys.exec_prefix
>>       self._chosen_module = ''
>>       self._user_search_path = ''
>>       self._this_module = ''
>>         def _SetVar(self, attr, val):
>>       self.attr = val            def _search_for_module(self, *args):
>>             """Private method which walks through default Python installation directories, and search for prefered module."""
>>             #walking thru all directories available in path '_user_search_path'
>>       for root, dirs, files in os.walk(self._user_search_path):
>>           for f in files:
>>                             #if found file 'f' is THAT module,
>>               #full path to THAT file is assigned to variable
>>               if f == ("%s.py" % self._chosen_module):
>>                   self._SetVar(self._this_module, os.path.join(root, f))
>>                                       def print_module(self, _chosen_module='', _user_search_path='', _default_search_path=sys.exec_prefix,):
>>             """Reads module chosen by user, and returns full content of this module, as it is."""
>>                   #if custom search path hasn't been assigned,
>>       #default path is being assigned as custom path
>>       if self._user_search_path == '':
>>           self._user_search_path = self._default_search_path
>>                 #using private method '_search_for_module' with 'self.' preffix
>>       #to search for prefered module
>>       self._search_for_module(_chosen_module, _user_search_path)
>>             #opening prefered module with read-only binary mode
>>       #and assigning it to 'module_open' variable
>>       module_open = open(self._this_module, 'rb')
>>             #reading this file and assigning it to variable
>>       module_text = module_open.read()
>>             #closing read file; the read content is still available
>>       #it's stored in variable 'module_text'
>>       module_open.close()
>>             #returning the read content
>>       return module_text
>>
>> "
>>
>> When i use this class in Python IDLE, i've got this error:
>> "
>>  >>> mod = ModPrint()
>>  >>> import socket
>>  >>> mod.print_module('socket')
>>
>> Traceback (most recent call last):
>>  File "<pyshell#60>", line 1, in <module>
>>   mod.print_module('socket')
>>  File "<pyshell#57>", line 48, in print_module
>>   module_open = open(self._this_module, 'rb')
>> IOError: [Errno 2] No such file or directory: ''
>>  >>>
>> "
>>
>> As You can see, i can't assign the new value "os.path.join(root, f)" to the 'self._this_module variable'.
>> So for sure i've made some mistake in method:
>>
>> "
>> def _SetVar(self, attr, val):
>>       self.attr = val   "
>> When i've changed private variables to normal, stored in class (in __init__ method), it was the same situation - i couldn't change this variable value.
>>
>> "
>>  >>> mod = ModPrint()
>>  >>> mod.print_module('os')
>>
>> Traceback (most recent call last):
>>  File "<pyshell#72>", line 1, in <module>
>>   mod.print_module('os')
>>  File "<pyshell#64>", line 48, in print_module
>>   module_open = open(self.this_module, 'rb')
>> IOError: [Errno 2] No such file or directory: ''
>>  >>>
>> "
>>
>> Thanks i someone could help me, give some hint.
>
> What is the point of the _SetVar method?
>
> Instead of:
>
>    self._SetVar(self._this_module, os.path.join(root, f))
>
> just do:
>
>    self._this_module = os.path.join(root, f)
>
> (unless I'm misunderstanding what you're trying to do!)
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list