Ask Your Question

Generating plane triangulations

asked 2013-12-21 14:22:30 +0100

hbm gravatar image

updated 2019-03-12 21:11:42 +0100

FrédéricC gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2013-12-21 17:12:04 +0100

fidbc gravatar image

updated 2013-12-21 17:12:28 +0100

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:
           s =
       except StopIteration:
           raise StopIteration("Exhausted list of graphs from plantri")
       G = graph.Graph(s[:-1], format='graph6')
       yield G
edit flag offensive delete link more


Thank you very much.

hbm gravatar imagehbm ( 2013-12-21 17:18:02 +0100 )edit

Would this work for all OS or just Unix/Linux system?

hbm gravatar imagehbm ( 2013-12-21 17:25:26 +0100 )edit

You're welcome. Not sure about that, I've only tested it on OSX and Linux.

fidbc gravatar imagefidbc ( 2013-12-21 17:35:51 +0100 )edit

answered 2019-03-13 09:31:22 +0100

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))
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-12-21 14:22:30 +0100

Seen: 801 times

Last updated: Mar 13 '19