[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-03 Thread sdobrev
yeah im no mathematician but i dont think you can use just part of a theory thats designed for flow diagrams with some totally different kind of diagram. well, relational algebra, or graph theory is just that, and can be used for wbatever one finds applicable. diff Application aspects may

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-03 Thread sdobrev
noting that, i have spent almost no time at all on supporting concrete patterns at this point (also, nobody has really complained). no worries, i've doing now a cut over proper graph, built in similar way as the one unitofwork's topology is using, scratch that, instead i propagated a

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
i am asking this, because so far i am considering both table/foregn-key graph and mapper/relation graph same, thus applying the mincut for the table/foregnkey (which sets fkey.use_alter=True) also to the other (which sets respective relation.post_update=True). And in 99% of cases, this works.

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
a circular relationship between two mappers means that a dependency sort revealed that the mapper-level dependency graph contains cycles. that portion of the sort is then thrown away and replaced with a dependency sort where the nodes are individual object instances. so sort #1 is mappers as

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
A mincut algorithm finds the minimal number of edges to cut in a cycled graph so it becomes without cycles. http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem i.e. applying such algorithm over the graph of table dependencies (foregnkey), one gets some minimal number of foreign keys to make

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
On Feb 2, 2007, at 10:33 AM, svilen wrote: A mincut algorithm finds the minimal number of edges to cut in a cycled graph so it becomes without cycles. http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem i.e. applying such algorithm over the graph of table dependencies (foregnkey), one

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread svilen
i think you are looking for a feedback arc set, which describes exactly the problem that applying post_update to a mapping solves: http://en.wikipedia.org/wiki/Feedback_arc_set and we actually generate a set like this in the _find_cycles() method, except it doesnt find just one edge of

[sqlalchemy] Re: what is considered circular dep at session.flush() ?

2007-02-02 Thread Michael Bayer
On Feb 2, 2007, at 2:14 PM, svilen wrote: of course, topological sort is a sort, but in order of it to work, the graph should not have cycles. Which are cut by use_alter's and post_updates, on foreign keys and relations. well, in our case all edges have cost of 1, except