Question: MATLAB Code Phase Transitions with Erdos and Renyi Build a random graph (of nodes/cells with no edges connecting them yet). Then build versions of it

MATLAB Code

Phase Transitions with Erdos and Renyi

Build a random graph (of nodes/cells with no edges connecting them yet). Then build versions of it that have more and more edges or arcs that connect pairs of nodes/cells. Measure the size of the largest connected network in each graph. Graph that network size as a proportion of the total graph, as a function of the ratio of edges to nodes. When averaged over 10 runs, the curve should look like Erdos & Renyis phase transition graph.

Clear your variables

Make a 10 by 50 matrix of zeros in which you will store the results of the 10 runs. Call it allmaxnet

Start a for loop where run goes from 1 to 10 Set x to zero and cells to 100

Start a for loop where edges goes from 5 to 250 in steps of 5 Increment x up by 1 Set m to a cellsXcells matrix of zeros Start a while loop that continues while the full total sum of m is less than edges

Set i to be a randomly selected cell (but not the last one) Set j to be a randomly selected cell that is greater then i (i and j are now indices) Place a 1 in the iXj cell of the m matrix

End the while loop

(Now that a given random graph has been built, you must measure the size of its largest connected network, and sending activation through it can help you do that.)

Make the edges into bidirectional synapse-like connections (add a transposed version of m to m)

Start a for loop where n goes from 1 to cells Set cellacts to a 1Xcells vector of zeros (this will be used to send activation through the network for identifying the largest connected network in the graph) Set the nth element of cellacts to 1

Start a for loop where t goes from 1 to cells Multiply cellacts by m and add that to cellacts

End that for loop

Set the nth element of netsize to the number of nonzero elements in cellacts End the for loop

Save the max of netsize in the xth element of maxnet end the edges loop

save maxnet as the runth row of allmaxnet end the overall loop plot along an x-axis of 0.05 to 2.5, in steps of .05, the mean of allmaxnet

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!