[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

dependency order

Bryan

2/9/2008 6:58:00 PM

i'm having trouble trying to figure this out... it's part of a build
system i'm writing in python. maybe someone has a good simple way to
solve this. i'm trying to create a dependency order out of multiple
lists.

list1: B C
list2: A B
list3: A C

i want the end result to be the list: A B C
i'm very frustrated that i can't come up with anything that always
works.


thanks... any clues to solve this would be greatly appreciated.

bryan
5 Answers

Diez B. Roggisch

2/9/2008 7:11:00 PM

0

belred@gmail.com schrieb:
> i'm having trouble trying to figure this out... it's part of a build
> system i'm writing in python. maybe someone has a good simple way to
> solve this. i'm trying to create a dependency order out of multiple
> lists.
>
> list1: B C
> list2: A B
> list3: A C
>
> i want the end result to be the list: A B C
> i'm very frustrated that i can't come up with anything that always
> works.
>
>
> thanks... any clues to solve this would be greatly appreciated.

Maybe the frustration is based on the IMHO wrong data-structure you use.
What does [B, C] mean?

A common approach for this is to create a dict instead, that maps an
object to the list of things it depends on (or that depend on it, it's
essentially the same)

The resulting data-structure is called a directed graph, and there are
algorithms like "partial orderings" you can google for that will help you.

An example graph would be:


dict(
"A" : ["B", "C"],
"B" : ["C"]
"C" : []
)

Then the result of a partial ordering would be

["C", "B", "A"]

which should be what you are after.

Diez

Bryan

2/9/2008 8:00:00 PM

0

On Feb 9, 11:10 am, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
> bel...@gmail.com schrieb:
>
> > i'm having trouble trying to figure this out... it's part of a build
> > system i'm writing in python. maybe someone has a good simple way to
> > solve this. i'm trying to create a dependency order out of multiple
> > lists.
>
> > list1: B C
> > list2: A B
> > list3: A C
>
> > i want the end result to be the list: A B C
> > i'm very frustrated that i can't come up with anything that always
> > works.
>
> > thanks... any clues to solve this would be greatly appreciated.
>
> Maybe the frustration is based on the IMHO wrong data-structure you use.
> What does [B, C] mean?
>
> A common approach for this is to create a dict instead, that maps an
> object to the list of things it depends on (or that depend on it, it's
> essentially the same)
>
> The resulting data-structure is called a directed graph, and there are
> algorithms like "partial orderings" you can google for that will help you.
>
> An example graph would be:
>
> dict(
> "A" : ["B", "C"],
> "B" : ["C"]
> "C" : []
> )
>
> Then the result of a partial ordering would be
>
> ["C", "B", "A"]
>
> which should be what you are after.
>
> Diez


i found this program in pypi, it does exactly what i was after :)

http://pypi.python.org/pypi/t...

>>> from topsort import topsort
>>> topsort([('B', 'C'),('A', 'B'),('A', 'C')])
['A', 'B', 'C']

very cool!!! i will be able to adapt this to my program without any
problems.



Gabriel Genellina

2/10/2008 3:55:00 AM

0

En Sat, 09 Feb 2008 16:57:44 -0200, <belred@gmail.com> escribi�:

> i'm having trouble trying to figure this out... it's part of a build
> system i'm writing in python. maybe someone has a good simple way to
> solve this. i'm trying to create a dependency order out of multiple
> lists.
>
> list1: B C
> list2: A B
> list3: A C
>
> i want the end result to be the list: A B C
> i'm very frustrated that i can't come up with anything that always
> works.

"Topological sort". There were two threads here last month.

http://groups.google.com/group/comp.lang.python/search?q=topological+sort&start=0&...

--
Gabriel Genellina

frice

3/21/2008 3:25:00 AM

0

Kim P <yduzitmatter@cogeco.ca> wrote:
>JAFAW wrote:
>> "JAFAW" <anon@anon.net> wrote in message
>> news:PvtEj.13806$jH5.11664@newsfe3-win.ntli.net...
>>> US Media - FOX NEWS: Church of Scientology: TASTELESS < epic epic epic
>>> winnage
>>> http://youtube.com/watch?v=e...
>> http://www.myfoxboston.com/myfox/pages/Home/Detail;jsessionid=79EBA62ED74095DBD6FE7CE738462BF1?contentId=2157697&version=2&locale=EN-US&layoutCode=VSTY&pageId=1.1.1&...
>> Sorry about the broken. Link. It's on the youtube page.
>> BTW this is from a report last year. It is absolutely sick what the
>> CCHR/$cientology does. Fox gives is epic win beyond the call of duty.
>> We need moarrrr stories like this to get spread around.
>http://www.metrowestdailynews.com/archive/...
>THis is a report about drivers being angered by the protest. Quite
>amazing how scientology manages to shoot itself in the foot everytime.

The man at the end of the original news report noted that he -- like
almost everyone who has some background in the issues -- agree that
doctors and what not are handing out narcotics and dope to kids in WAY
too much large quantities that are outrageous and CRIMINAL. But when
some insane Scientology crook opens his yap to denounce what everyone
already agrees is abuse that should be stopped, everyone is turned off
of the issue. Scientology shits all over the REAL effort to curtail
medication abuses because Scientology's insane excesses makes anyone
who legitimately opposes over drugging look tainted by the Scientology
shitspew.

You see it in the blogs and on newspaper opinions. Any place where
someone is allowed to have their say and condemns over drugging, there
are people who automatically attribute the comments to the extremist,
insane Scientology crime syndicate, ergo the problem doesn't get
addressed rationally. Scientology has shit all over the problem to the
point where anyone who wants to fix it are equated to being Scientology
crooks.

---
Anonymous = Herd of Cats Latched on to the Same Wildebeest

Scientology is a cult

3/21/2008 1:49:00 PM

0

FRice@SkepticTank.Org (Fredric L. Rice) wrote in
news:13u7hc3jocb3p0b@corp.supernews.com:

> Kim P <yduzitmatter@cogeco.ca> wrote:
>>JAFAW wrote:
>>> "JAFAW" <anon@anon.net> wrote in message
>>> news:PvtEj.13806$jH5.11664@newsfe3-win.ntli.net...
>>>> US Media - FOX NEWS: Church of Scientology: TASTELESS < epic epic
>>>> epic winnage
>>>> http://youtube.com/watch?v=e...
>>> http://www.myfoxboston.com/myfox/pages/Home/Detail;jsession...
>>> ED74095DBD6FE7CE738462BF1?contentId=2157697&version=2&locale=EN-US&la
>>> youtCode=VSTY&pageId=1.1.1&sflg=1 Sorry about the broken. Link. It's
>>> on the youtube page. BTW this is from a report last year. It is
>>> absolutely sick what the CCHR/$cientology does. Fox gives is epic
>>> win beyond the call of duty. We need moarrrr stories like this to
>>> get spread around.
>>http://www.metrowestdailynews.com/archive/...
>>THis is a report about drivers being angered by the protest. Quite
>>amazing how scientology manages to shoot itself in the foot everytime.
>
> The man at the end of the original news report noted that he -- like
> almost everyone who has some background in the issues -- agree that
> doctors and what not are handing out narcotics and dope to kids in WAY
> too much large quantities that are outrageous and CRIMINAL. But when
> some insane Scientology crook opens his yap to denounce what everyone
> already agrees is abuse that should be stopped, everyone is turned off
> of the issue. Scientology shits all over the REAL effort to curtail
> medication abuses because Scientology's insane excesses makes anyone
> who legitimately opposes over drugging look tainted by the Scientology
> shitspew.
>
> You see it in the blogs and on newspaper opinions. Any place where
> someone is allowed to have their say and condemns over drugging, there
> are people who automatically attribute the comments to the extremist,
> insane Scientology crime syndicate, ergo the problem doesn't get
> addressed rationally. Scientology has shit all over the problem to
> the point where anyone who wants to fix it are equated to being
> Scientology crooks.

I agree 9001%. I myself am extremely turned off at the idea of
medicating "trouble" students because they'd rather doodle on their
notebook than solve math problems. Turning a classroom into a collection
of drones is one of the more disturbing aspects of modern education.
However, no one can talk about this because Scientologists have fucked up
the chance of reasonable dialogue and communication.

Truth of the matter, if Scientology wants to destroy psychiatry, all they
have to do is put out one single press release saying they side with
them. The industry would be devastated and everyone involved would be
out of a job in under a week.

This is because of the continual failures of inherently flawed LRH tech
to deal with the problem. That's the problem when a dangerous, criminal
cult founded by a sociopathic crook opens its yap on any issue.

Hubbard thought he was clever. This was his primary error. Good luck.

--
Posted via a free Usenet account from http://www.te...