Ask Your Question

Revision history [back]

The current interface of plantri is incomplete. Indeed, we cannot specify the number of edges or an upper bound on the size if a face. The following method should do what you want.

import subprocess

def foo(n):
    """
    Iterator over planar graphs of order n, size 2n, minimum degree 4
    and faces of size at most 4
    """
    from sage.features.graph_generators import Plantri
    Plantri().require()
    if n < 6:
        return

    command = 'plantri -pm4c0e{}f4 {}'.format(2*n, n)

    sp = subprocess.Popen(command, shell=True,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE, close_fds=True,
                              encoding='latin-1')

    sp.stdout.reconfigure(newline='')
    print(sp.stdout)
    for G in graphs._read_planar_code(sp.stdout):
        if G.is_regular(4):
            yield(G)

I'll let it run for n=25 and let you know if it finds solutions (it might take a very long time).

The current interface of plantri is incomplete. Indeed, we cannot specify the number of edges or an upper bound on the size if a face. The following method should do what you want.

import subprocess

def foo(n):
    """
    Iterator over planar graphs of order n, size 2n, minimum degree 4
    and faces of size at most 4
    """
    from sage.features.graph_generators import Plantri
    Plantri().require()
    if n < 6:
        return

    command = 'plantri -pm4c0e{}f4 {}'.format(2*n, n)

    sp = subprocess.Popen(command, shell=True,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE, close_fds=True,
                              encoding='latin-1')

    sp.stdout.reconfigure(newline='')
    print(sp.stdout)
     for G in graphs._read_planar_code(sp.stdout):
        if G.is_regular(4):
            yield(G)

I'll let it run for n=25 and let you know if it finds solutions (it might take a very long time).