Example #1
0
def net_state_transition(G, nodes_list):
    ''':
        Arguments:
            G [networkx Graph object]
            
            nodes_list [list of strs]
                list of nodes in the network
        Return:
            G_transition_graph [networkx Graph object]
                networkx graph directed graph showing how network configurations map to one another in a deterministic system
                XXXTHIS TRANSITION GRAPH IS DEPENDENT ON THE STARTING STATE OF G BECAUSE IT ONLY MAPS THE STATE TRANSTITIONS
                XXXFROM THAT STARTING STATE. IT SHOULD BE SHOWING THE ATTRACTOR LANDSCAPE REGARDLESS OF YOUR STARTING POSITION.
                XXXI THINK IT IS MESSING UP BECAUSE I AM PASSING G THROUGH THE BOOLEAN UPDATING FUNCTION.
                4/13/16 4:44pm- FIXED. now this should show the complete transition graph. Still need to check to make sure
                that the attractors being output are accessible from the specified initial state though.

    '''
    
    n_nodes = len(G.nodes())
    n_init_networks = n_states**n_nodes
    G_transition_graph = nx.DiGraph()

    for prev_network_ID in range(0, n_init_networks):

        prev_network_bID = decimal_to_binary(nodes_list, prev_network_ID)
        network_bID = ur.boolean_updating(G, prev_state=prev_network_bID)
        network_ID = binary_to_decimal(nodes_list, network_bID)
        G_transition_graph.add_edge(prev_network_ID, network_ID) #this is a directed graph showing you attractor landscape for how each of the states trasitions to each other
    
    return G_transition_graph
Example #2
0
def time_series_all(G, nodes_list, timesteps=20):
    ''':
        Applies boolean updating rule to the network nodes for the specified number of timesteps.
        AND
        Applies boolean updating rule to the network nodes accross ALL possible initial network states.

        Arguments:
            G [networkx Graph object]

            nodes_list [list of strs]
                list of nodes in the network

            timesteps [int]
                number of timesteps for network to evolve
        
        Return:
            timeseriesdata [dict of (dict of list of ints)]
                ex. {'gC': {0: [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], 1: [1, 0, 0, 1, 0, 0, 1, 0, 0, 1],...}, 'gF': {...}} 
                innermost list (ex. [0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) - timeseries of states of the node
                innermost key (ex. 0)- network_ID specificing the initial state of all nodes in the network
                outermost key (ex. 'gC')- node_ID specifing the node whose states are being listed
    '''
    
    n_nodes = len(G.nodes()) # number of nodes in network
    n_init_networks = n_states**n_nodes # number of possible initial network states
    
    timeseriesdata = {}
    ## Create empty time series list for every combination 
    ## of node and initial network state
    for node in G.nodes():
        timeseriesdata[node] = {}
        for network_ID in range(0, n_init_networks):
            timeseriesdata[node][network_ID] = [] 
    
    ## Fill time series list with individual node states for 
    ## every combination of node and initial network state
    for network_ID in range(0, n_init_networks):
        network_bID = decimal_to_binary(nodes_list, network_ID)
        for step in range(0, timesteps):
            prev_network_bID = network_bID.copy()
            for node in nodes_list:
                timeseriesdata[node][network_ID].append(prev_network_bID[node])
            network_bID = ur.boolean_updating(G, prev_network_bID)

    return timeseriesdata