Created
February 2, 2017 14:49
-
-
Save RobertTalbert/9561e888ba0db73d843c887a1d15c766 to your computer and use it in GitHub Desktop.
Code for Guided Practice 7, MTH 325
This file contains 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
# Import networkx | |
import networkx as nx | |
# Import two functions from the "random" library: | |
# randint(a,b) generates a random integer between a and b | |
# random() generates a random floating point number between 0 and 1 | |
from random import random, randint | |
# Generates 5 random graphs with random numbers of nodes and | |
# connection probabilities, and prints off their dictionaries. | |
for i in range(5): | |
n = randint(2, 10) | |
p = random() | |
g = nx.random_graphs.gnp_random_graph(n,p) | |
print(nx.to_dict_of_lists(g)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment