Hi,

I have just build two patterns based on Elixir :

Topology for topological sorting
    A
  /  \
 B   C
  \ /
   D

B -> A
C -> A (priority 10)
D -> B
D -> C

c = Task(name=u'C', brief=u'Hi, mom!', priority=-10.0) # this is very
important!
a = Task(name=u'A', brief=u'This is a important task!')
d = Task(name=u'D', brief=u'Get every thing done')
b = Task(name=u'B', brief=u'Well..It is not so imporant')

ba = Dependency(fromNode=b, toNode=a)
ca = Dependency(fromNode=c, toNode=a)
db = Dependency(fromNode=d, toNode=b)
dc = Dependency(fromNode=d, toNode=c)

You can get right order to do these tasks by doing so:

tasks = Task.query.all()
sortNodes(tasks)

And there are some other algorithm: cycle detection, change tracing.

Another pattern : Formula for storing formula in database, and
calculate them.

a = FormulaMeta(Variable(key='a'))
b = FormulaMeta(Variable(key='b'))

formula = getFormula( ((a + b) * (b - a + 1)) / 2 )

print formula.calculate(a=1, b=100)
print formula.calculate(a=1, b=1000)
print formula.calculate(a=500, b=1000)

You can find them at:
http://elixir.ematia.de/trac/wiki/Recipes/Topology
http://elixir.ematia.de/trac/wiki/Recipes/Formula

I would be happy if someone refine them, extend them. You can build
other patterns. That would be powerful weapon to handle complex
problem based on database. Thanks OO design, Elixir and SQLAlchemy.
They can be used, reused and extended easily! :D

Victor Lin.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to