On Feb 7, 4:11 am, [EMAIL PROTECTED] wrote: > Suresh: > > > I could find GeoSteiner (http://www.diku.dk/geosteiner/) which is > > implemented as a C program. Anybody know python wrapper for this? > > Anybody tried this program in a python program? > > Once compiled, you may just need to use it with files calling it > through the console with pipes from Python. If that isn't enough, you > can probably write a simple enough wrapper using Pyrex. > If you succed, I may be interested in the result. > > Bye, > bearophile
bearophile, Thanks for the response. I could compile the program. I am now doing this with pipes only; but only thing is that, I had to parse the ps output myself, to generate the line segements, which looks ugly and fails in some cases. Did you find any other way to directly get the new line segments and steiner points. import popen2,re def steiner(points): process = popen2.Popen3('/path/rfst |\ /path/prunefst \ | /path/bb') for pt in points: process.tochild.write('%f %f\n' % (pt[0], pt[1])) process.tochild.close() process.wait() BeginPlot=False EndPlot=False lineSegments = [] for line in process.fromchild: if not EndPlot: if BeginPlot: if line == 'EndPlot\n': EndPlot = True else: if not (re.match('^\s.*%', line) \ or re.match('\s*Plot_Terminals', line) \ or re.match('^\s*\(', line)\ ): #print line a,b,c,d,j = line.split() if b == 'T': p1 = points[int(a)] else: p1 = (float(a),float(b)) if d == 'T': p2 = points[int(c)] else: p2 = (float(c), float(d)) if not(p1[0] == p2[0] and p1[1] == p2[1]): lineSegments.append((p1,p2)) else: if line == 'BeginPlot\n': BeginPlot=True return(lineSegments) I want to write the code with pyrex, but the c program looks complicated. Maybe with some help in understanding from you, we can write the wrapper with pyrex. - Suresh -- http://mail.python.org/mailman/listinfo/python-list