Dave Griffiths wrote:

I could have a quick go at fixing it up in the harness, give you something you
can drop in and try. Maybe code it so you can flip an alternative
algorithm in and out.


Done it:

http://www.sbibble.pwp.blueyonder.co.uk/GraphSort.C
http://www.sbibble.pwp.blueyonder.co.uk/GraphSort.h

Nothing changes until/unless you either
a) compile with GRAPHSORT_USE_TEST_SORT_BY_DEFAULT defined
b) pass 'true' into the constructor OR
c) call GraphSort::TestSort() instead of GraphSort::Sort()

In any of which cases it uses the new TestSort() instead of the original
Sort(). This tries to replicate the original sort's quirks, whilst eliminating
the actual sort error.


Would need to know...
1) the exact semantics of "Terminal"... which nodes are marked
terminal and why. I can see how/where they're marked, but haven't
looked into why. (Maybe I should just read the code).


Terminals are outputs...

there are input terminals but they are not used in 0.2.0...



Output terminal modules (OSS,Jack,DiskWriter)


Hadn't run ssm (I have now) so didn't know if outputs on a terminal
were feedback from the graph outputs or if they were inputs, ie it was
an I/O module.

are needed to be flagged
to resolve perfectly circular patches (eg Jack -> Echo -> Jack). The
Graphsort falls back on this if it can't find a root by itself.

... and didn't understand this as being "circular"... I see it as a straight line
that comes in, through and out of the app, so I thought "terminals" must
be somewhere on a free-floating circle of modules. I see now what you
mean by circular.


2) any non-obvious requirements on the sort order.
3) how, if at all, the rest of the app is sensitive to the internal implementation
of the GraphSort class.


Sort is only called from GraphSort.C seems to be ok for you....



Indeed, the implementation shouldn't affect anything else. No special requirements that I can think of, except it shouldn't be too slow, but it's currently a recursive function it probably couldn't get much slower - and it doesn't impact the performance at the moment.

OK. TestSort() manages to avoid recursion by using an intermediate list.

Note: I've tried to give this a half decent test, and it does seem to work every
time, but your original code has executed successfully about a zillion times
more than this code has...


Simon Jenkins
(Bristol, UK)




Reply via email to