Multiplex Network Pseudocode: Difference between revisions
From Santa Fe Institute Events Wiki
Line 5: | Line 5: | ||
=== Basic Edge With Complex Attributes === | === Basic Edge With Complex Attributes === | ||
<tt> | <tt> | ||
# This code take digraph object G with N nodes and L links and generate links with 2x2 matrix representing the payoffs. | |||
def initEdge(G,N,L): | def initEdge(G,N,L): | ||
for l in range(L): | for l in range(L): | ||
Line 10: | Line 12: | ||
j=rng.randrange(N) | j=rng.randrange(N) | ||
payoff = np.matrix([[rng.random() for e in range(2)] for e in range(2)]) | payoff = np.matrix([[rng.random() for e in range(2)] for e in range(2)]) | ||
G.add_edge(i,j,w=payoff) | G.add_edge(i,j,w=payoff) | ||
G.add_edge(j,i,w=payoff.transpose()) | G.add_edge(j,i,w=payoff.transpose()) |
Revision as of 19:27, 18 June 2014
Generating Network
Node Creation
Edge Creation
Basic Edge With Complex Attributes
- This code take digraph object G with N nodes and L links and generate links with 2x2 matrix representing the payoffs.
def initEdge(G,N,L):
for l in range(L): i=rng.randrange(N) j=rng.randrange(N) payoff = np.matrix([[rng.random() for e in range(2)] for e in range(2)]) G.add_edge(i,j,w=payoff) G.add_edge(j,i,w=payoff.transpose()) return G