Commit b4f4e99e by Guttorm.Alendal

### Delete thinkcomplexity.py

parent 6820be21
 # This Python file uses the following encoding: utf-8 from __future__ import print_function, division import matplotlib.pyplot as plt import networkx as nx import numpy as np import random # colors from our friends at http://colorbrewer2.org COLORS = ['#8dd3c7','#ffffb3','#bebada','#fb8072','#80b1d3','#fdb462', '#b3de69','#fccde5','#d9d9d9','#bc80bd','#ccebc5','#ffed6f'] def all_pairs(nodes): """Generates all pairs of nodes.""" for i, u in enumerate(nodes): for j, v in enumerate(nodes): if i < j: yield u, v def make_complete_graph(n): """Makes a complete graph with `n` nodes.""" G = nx.Graph() nodes = range(n) G.add_nodes_from(nodes) G.add_edges_from(all_pairs(nodes)) return G def flip(p): """Returns True with probability `p`.""" return random.random() < p def random_pairs(nodes, p): """Generates random pairs of nodes. Each possible edge is yielded with probability `p`. """ for i, u in enumerate(nodes): for j, v in enumerate(nodes): if i
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!