ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 21 Dec 2013 10:35:51 -0600Generating plane triangilationhttp://ask.sagemath.org/question/10851/generating-plane-triangilation/Does sage have a function that generates plane triangulations? Something like PLANTRI? If not, is it possible to use plantri from within sage and how?
Thank youSat, 21 Dec 2013 07:22:30 -0600http://ask.sagemath.org/question/10851/generating-plane-triangilation/Answer by fidbc for <p>Does sage have a function that generates plane triangulations? Something like PLANTRI? If not, is it possible to use plantri from within sage and how?</p>
<p>Thank you</p>
http://ask.sagemath.org/question/10851/generating-plane-triangilation/?answer=15852#post-id-15852If you have plantri installed and somewhere in your PATH variable you can easily adapt the code of `graphs.nauty_geng` to make it work with plantri. Something along the following lines might do the job:
def plantri(self, options=""):
import subprocess
sp = subprocess.Popen("plantri -g {0}".format(options), shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
gen = sp.stdout
while True:
try:
s = gen.next()
except StopIteration:
raise StopIteration("Exhausted list of graphs from plantri")
G = graph.Graph(s[:-1], format='graph6')
yield GSat, 21 Dec 2013 10:12:04 -0600http://ask.sagemath.org/question/10851/generating-plane-triangilation/?answer=15852#post-id-15852Comment by hbm for <p>If you have plantri installed and somewhere in your PATH variable you can easily adapt the code of <code>graphs.nauty_geng</code> to make it work with plantri. Something along the following lines might do the job:</p>
<pre><code>def plantri(self, options=""):
import subprocess
sp = subprocess.Popen("plantri -g {0}".format(options), shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
gen = sp.stdout
while True:
try:
s = gen.next()
except StopIteration:
raise StopIteration("Exhausted list of graphs from plantri")
G = graph.Graph(s[:-1], format='graph6')
yield G
</code></pre>
http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16515#post-id-16515Would this work for all OS or just Unix/Linux system?Sat, 21 Dec 2013 10:25:26 -0600http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16515#post-id-16515Comment by hbm for <p>If you have plantri installed and somewhere in your PATH variable you can easily adapt the code of <code>graphs.nauty_geng</code> to make it work with plantri. Something along the following lines might do the job:</p>
<pre><code>def plantri(self, options=""):
import subprocess
sp = subprocess.Popen("plantri -g {0}".format(options), shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
gen = sp.stdout
while True:
try:
s = gen.next()
except StopIteration:
raise StopIteration("Exhausted list of graphs from plantri")
G = graph.Graph(s[:-1], format='graph6')
yield G
</code></pre>
http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16516#post-id-16516Thank you very much.Sat, 21 Dec 2013 10:18:02 -0600http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16516#post-id-16516Comment by fidbc for <p>If you have plantri installed and somewhere in your PATH variable you can easily adapt the code of <code>graphs.nauty_geng</code> to make it work with plantri. Something along the following lines might do the job:</p>
<pre><code>def plantri(self, options=""):
import subprocess
sp = subprocess.Popen("plantri -g {0}".format(options), shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
gen = sp.stdout
while True:
try:
s = gen.next()
except StopIteration:
raise StopIteration("Exhausted list of graphs from plantri")
G = graph.Graph(s[:-1], format='graph6')
yield G
</code></pre>
http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16514#post-id-16514You're welcome. Not sure about that, I've only tested it on OSX and Linux.Sat, 21 Dec 2013 10:35:51 -0600http://ask.sagemath.org/question/10851/generating-plane-triangilation/?comment=16514#post-id-16514