0
$\begingroup$

I need to devise a algorithm (in Python) that calculates adjacency matrices for the platonic solids. Inputted into the algorythm needs to be the number of polygons meeting at each vertex and the regular polygon on which they are based. Any ideas are welcome as I've tried a few avenues and haven't come up with anything remotely successful.

Let the number of sides n and let the number of vertexes connected to any particular vertex be m.

Take a tetrahedron, it has n = 3 and m = 3. My problem is then going from this to establishing the following adjacency matrix.

0 1 1 1
1 0 1 1
1 1 0 1
1 1 1 0

This is therefore the adjacency matrix for a tetrahedron. With a cube, it becomes more complicated

0 1 1 0 1 0 0 0
1 0 0 1 0 1 0 0
1 0 0 1 0 0 1 0
0 1 1 0 0 0 0 1 
1 0 0 0 0 1 1 0
0 1 0 0 1 0 0 1
0 0 1 0 1 0 0 1 
0 0 0 1 0 1 1 0     

etc.

So i need to take the values of n, and m and calculate these matrices. Clearly there are many possible solutions depending on how the algorithm labels the vertexes. Any ideas?

$\endgroup$
  • $\begingroup$ I find this question to be a little bit vague/confusing, particularly the second sentence. Could you provide an small example? Also you mentioned you tried a few avenues but didn't say what they were. This might be just me - this isn't what I have experience in - but it might be more helpful to others if you can add a little bit more detail (maybe a picture/graph of what your problem looks like?). $\endgroup$ – James Dec 24 '15 at 0:57
  • 1
    $\begingroup$ I must be missing a part of the problem... There are five platonic solids (with my definition, at least), so you can simply precompute those five matrices (and I'd be surprised if they weren't already easily available somewhere on the internet) and return them. $\endgroup$ – Federico Poloni Dec 24 '15 at 16:35
  • 1
    $\begingroup$ Also, have you checked doc.sagemath.org/html/en/reference/graphs/sage/graphs/… ? $\endgroup$ – Federico Poloni Dec 24 '15 at 16:37
  • $\begingroup$ @FedericoPoloni i have done as you suggested. i gave up on trying to compute them directly. i sourced them from the data contained within mathematica $\endgroup$ – duhamp Dec 24 '15 at 17:09
  • $\begingroup$ @FedericoPoloni: I think the sage commands to construct the five Platonic solid graphs on the page you pointed out, together with the method g.adjacency_matrix(), would be worth posting as an Answer. $\endgroup$ – hardmath Dec 24 '15 at 19:13
1
$\begingroup$

As suggested by @hardmath, a simple Sage solution:

def platonic_solid_adjacency_matrix(n,m):
    """
    Adjacency matrix of the Platonic solid with `n` sides and in which each vertex has `m` neighbors.
    """

    d = {(6,3):graphs.TetrahedralGraph, (12,3):graphs.HexahedralGraph, 
        (12,4):graphs.OctahedralGraph, (30,3):graphs.DodecahedralGraph, (30,5):graphs.IcosahedralGraph}
    try:
        return d[(n,m)]().adjacency_matrix()
    except KeyError:
        raise ValueError, "There is no Platonic solid with the supplied parameters"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.