Ask Your Question
1

Generating plane triangulations

asked 11 years ago

hbm gravatar image

updated 6 years ago

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

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
4

answered 11 years ago

fidbc gravatar image

updated 11 years ago

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
Preview: (hide)
link

Comments

Thank you very much.

hbm gravatar imagehbm ( 11 years ago )

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

hbm gravatar imagehbm ( 11 years ago )

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

fidbc gravatar imagefidbc ( 11 years ago )
3

answered 6 years ago

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
Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 1,049 times

Last updated: Mar 13 '19