def elegant_layout(G): ''' Given networkx graph G, return a nice elegant layout. ''' seed = nx.spring_layout(G) return run_simulation(G,seed)
def demo(): ''' Run a demo showing how a random, ugly network graph evolves into a much nicer-looking graph. ''' size = 8 G = nx.gnm_random_graph(size,11) seed = nx.spring_layout(G) evol = run_simulation(G,seed)
def test_triangle(self): G = nx.Graph() G.add_edges_from([(1,2), (1,3), (2,3)]) layout = {1: (0.2,0.2), 2: (0.8, 0.2), 3: (0.5, 0.8)} run_simulation(G, layout)
def test_rhombus(self): G = nx.Graph() G.add_edges_from([(1,2), (2,3), (3,4), (4,1)]) layout = {1: (0.2,0.2), 2: (0.5, 0.2), 3: (0.8, 0.8), 4: (0.5,0.8)} run_simulation(G, layout)
def elegantify_layout(G, seed): ''' Given networkx graph G and a layout, attempt to find an improvement to the layout and return it. ''' return run_simulation(G,seed)