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 you
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 you
If 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 G
plantri 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
Asked: 2013-12-21 07:22:30 -0600
Seen: 495 times
Last updated: Mar 13 '19
How do I get the external face of a planar embedded graph?
Combinatorial data for planar graph
How to create random cubic planar graphs?
embed planar graph with prescribed outer face
Drawing a planar multigraph with loops
networkx can't compute algebraic connectivity
How to generate random graphs free of certain structures?
Finding all shortest paths between given (specific) pair of vertices