Surface of the 3x3x3 cube as a graph

APL (Dyalog Classic), 34 30 bytes

-4 thanks to jimmy23013

4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3

Try it online!

outputs an adjacency matrix with each vertex adjacent to itself

⍳3 3 generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)

multiply all by π

7 ¯1∘., prepend 7 or -1 in all possible ways

(⍳3)∘.⌽ rotate coord triples by 0 1 2 steps in all possible ways

+/¨|∘.-⍨, compute manhattan distance between each pair

4≥ it must be no greater than 4 for neighbouring facets


Ruby, 60 bytes

i=0;("$$5$$1$Hu"*6).bytes{|j|p [(j/18+i+=1)%54,(j%18+i)%54]}

Try it online!

Improved version of my original answer. We split the surface of the cube into squares of 9 (instead of rectangles of 18 as before) and use a magic string rather than a formula to generate the offsets. The output is a list of the nodes below and to the right of each node in the (revised) map below, as before.

Output map in base 10 as shown in the output

(each node is linked to the nodes below and to the right)

0  3  6  9 10 11
1  4  7 12 13 14
2  5  8 15 16 17
        18 21 24 27 28 29
        19 22 25 30 31 32
        20 23 26 33 34 35
                 36 39 42 45 46 47
                 37 40 43 48 49 50
                 38 41 44 51 52 53

Output map in base 9 (to show more clearly how it works.)

Note that each square of 9 has the same first digit. The last digits repeat 0,1,2 on the free edge and 0,3,6 on the attached edge (alternating between horizontal and vertical.)

In one direction the next node is 3 higher (except when crossing to the next square, when it is 3,5 or 7 higher) and in the other direction it is 1 higher (except when crossing to the next square, when it is [base 10] 18, 14 or 10 higher = [base 9] 20, 16 or 12 higher.)

This info is encoded into the magic string, where the ASCII code of each character is 18*[2,4 or 6]+[17,13,10 or 0]. Incrementing i at the beginning of each iteration boosts these values by 1.

00 03 06 10 11 12
01 04 07 13 14 15
02 05 08 16 17 18
         20 23 26 30 31 32
         21 24 27 33 34 35
         22 25 28 36 37 38
                  40 43 46 50 51 52
                  41 44 47 53 54 55
                  42 45 48 56 57 59

Ruby, 79 bytes

54.times{|i|p [(i%6<5?i+1:i+18-i/6%3*7)%54,(i+=i%18<12?6:[18-i%6*7,3].max)%54]}

Try it online!

Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.

 0  1  2  3  4  5   
 6  7  8  9 10 11   
12 13 14 15 16 17   
         18 19 20 21 22 23
         24 25 26 27 28 29
         30 31 32 33 34 35
                  36 37 38 39 40 41
                  42 43 44 45 46 47 
                  48 49 50 51 52 53

Python 2.7, 145

def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]

Try it online!

Defines an adjacency matrix x as a list of lists of boolean values. Facets count as being adjacent to themselves.

p(n) computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).