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.Wed, 13 Mar 2019 03:31:22 -0500Generating plane triangulationshttp://ask.sagemath.org/question/10851/generating-plane-triangulations/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-triangulations/Answer by David Coudert 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-triangulations/?answer=45774#post-id-45774plantri is an optional package that you can install using
> sage -i plantri
You will then be able to use the iterator over connected planar triangulations
sage: list(graphs.triangulations(6))
[Graph on 6 vertices, Graph on 6 vertices]
sage: all(g.is_planar() for g in graphs.triangulations(10))
True
Wed, 13 Mar 2019 03:31:22 -0500http://ask.sagemath.org/question/10851/generating-plane-triangulations/?answer=45774#post-id-45774Answer 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-triangulations/?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-triangulations/?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-triangulations/?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-triangulations/?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-triangulations/?comment=16516#post-id-16516Thank you very much.Sat, 21 Dec 2013 10:18:02 -0600http://ask.sagemath.org/question/10851/generating-plane-triangulations/?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-triangulations/?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-triangulations/?comment=16514#post-id-16514