squared matrix of a graph?

27 Views Asked by At

I am new to graph theory, I am working with DAGs.

I came across this code, that when working with 3 nodes it did:

dag2=dag2+(dag %^% 2)

When it had 4 nodes:

for(i in 2:3)
    dag2=dag2+(dag %^% i)

I do understand the code, but I don't know what this means graphically. My question is, what is this doing graphically: what means to square or cube the matrix representation of a graph?