analytics

Thursday, April 17, 2014

modular additive network

Suppose you have a graph like the following:
I first fill in some starting values for all the nodes:
Call this State 1. State 2 is generated by adding the values of all nodes connected to a node and itself, then modding by a certain amount and adding 1. So if the mod amount is 7. The node with a 3 in state 1 would add 3+6+2 = 11, 11 mod 7 = 4, 4+1 = 5. so State 2 would have a 5 where the 3 is now.

It's interesting how long it takes to repeat the initial state, here are the first few States...
[2, 5, 2, 5, 6, 3]
[7, 1, 5, 5, 5, 5]
[3, 5, 3, 5, 7, 2]
[3, 3, 7, 7, 7, 6]
[7, 7, 6, 7, 3, 7]
[3, 7, 3, 4, 3, 3]
[7, 4, 6, 4, 3, 3]
[4, 1, 3, 5, 3, 6]
[3, 7, 4, 7, 1, 6]
[2, 1, 1, 5, 1, 5]
[4, 3, 4, 3, 1, 1]
[2, 1, 7, 5, 7, 7]
[2, 2, 4, 2, 1, 1]
...
This particular configuration repeated every 159 states. It's interesting that changing the initial values of all the nodes to some other number less than 8 for M = 7 still repeats after 159 iterations. Different M values repeat after different amounts of iteration, like M=11 repeats after 189...
source code:
graph = [[0,1,1,1,1,0],[1,0,1,1,0,0],[1,1,0,0,1,1],[1,1,0,0,1,0],[1,0,1,1,0,1],[0,0,1,0,1,0]]
amountsold = [7,5,3,5,4,3]
a = [7,5,3,5,4,3]
def add(graph, amounts):
    amountsnew = []
    for i in range(0, len(graph)):
        amount = amounts[i]
        for j in range(0, len(graph[i])):
            amount += graph[i][j]*amounts[j]
        amountsnew.append(amount%11+1)
    return amountsnew
print amountsold
for i in range(0, 1000):
    amountsold = add(graph, amountsold)
    if amountsold == a:
        print(i)

No comments:

Post a Comment