Last active
December 19, 2020 00:05
-
-
Save ThiagoFPMR/355f0d667d41fb6bde752068539b27b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parameters for our Synthetic Network | |
num_of_nodes = 100 # Total number of nodes (which are, in our case, people) | |
edges_per_node = 4 # Amount of relations a given person(node) will have by default | |
prob_of_triangle = 0.1 # Chance of a triangle happening given a relation | |
# Defining The Network | |
G = nx.powerlaw_cluster_graph(num_of_nodes, edges_per_node, prob_of_triangle) | |
# Defining The Attributes | |
node_size = {node:len(G[node])*50 for node in G.nodes} | |
node_neighbors = {node:len(G[node]) for node in G.nodes} | |
infected = False | |
# Setting The Attributes | |
nx.set_node_attributes(G, node_size, "size") | |
nx.set_node_attributes(G, node_neighbors, "neighbors") | |
nx.set_node_attributes(G, infected, "covid") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment