def IcosahedralGraph(): """ Returns an Icosahedral graph (with 12 nodes). The regular icosahedron is a 20-sided triangular polyhedron. The icosahedral graph corresponds to the connectivity of the vertices of the icosahedron. It is dual to the dodecahedral graph. The icosahedron is symmetric, so the spring-layout algorithm will be very effective for display. PLOTTING: The Icosahedral graph should be viewed in 3 dimensions. We chose to use the default spring-layout algorithm here, so that multiple iterations might yield a different point of reference for the user. We hope to add rotatable, 3-dimensional viewing in the future. In such a case, a string argument will be added to select the flat spring-layout over a future implementation. EXAMPLES: Construct and show an Octahedral graph :: sage: g = graphs.IcosahedralGraph() sage: g.show() # long time Create several icosahedral graphs in a Sage graphics array. They will be drawn differently due to the use of the spring-layout algorithm. :: sage: g = [] sage: j = [] sage: for i in range(9): ... k = graphs.IcosahedralGraph() ... g.append(k) ... sage: for i in range(3): ... n = [] ... for m in range(3): ... n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ... j.append(n) ... sage: G = sage.plot.graphics.GraphicsArray(j) sage: G.show() # long time """ import networkx G = networkx.icosahedral_graph() pos = {} r1 = 5 r2 = 2 for i,v in enumerate([2,8,7,11,4,6]): i = i + .5 pos[v] = (r1*cos(i*pi/3),r1*sin(i*pi/3)) for i,v in enumerate([1,9,0,10,5,3]): i = i + .5 pos[v] = (r2*cos(i*pi/3),r2*sin(i*pi/3)) return graph.Graph(G, name="Icosahedron", pos = pos)
def test_icosahedral(): G=nx.icosahedral_graph() for flow_func in flow_funcs: assert_equal(5, nx.node_connectivity(G, flow_func=flow_func), msg=msg.format(flow_func.__name__)) assert_equal(5, nx.edge_connectivity(G, flow_func=flow_func), msg=msg.format(flow_func.__name__))
def test200_icosahedralgraph(self): """ Icosahedral graph. """ g = nx.icosahedral_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) #td.showGraph(g, mate1, "test200_icosahedralgraph") self.assertEqual( len(mate1), len(mate2) )
def IcosahedralGraph(): """ Returns an Icosahedral graph (with 12 nodes). The regular icosahedron is a 20-sided triangular polyhedron. The icosahedral graph corresponds to the connectivity of the vertices of the icosahedron. It is dual to the dodecahedral graph. The icosahedron is symmetric, so the spring-layout algorithm will be very effective for display. PLOTTING: The Icosahedral graph should be viewed in 3 dimensions. We chose to use the default spring-layout algorithm here, so that multiple iterations might yield a different point of reference for the user. We hope to add rotatable, 3-dimensional viewing in the future. In such a case, a string argument will be added to select the flat spring-layout over a future implementation. EXAMPLES: Construct and show an Octahedral graph :: sage: g = graphs.IcosahedralGraph() sage: g.show() # long time Create several icosahedral graphs in a Sage graphics array. They will be drawn differently due to the use of the spring-layout algorithm. :: sage: g = [] sage: j = [] sage: for i in range(9): ... k = graphs.IcosahedralGraph() ... g.append(k) ... sage: for i in range(3): ... n = [] ... for m in range(3): ... n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ... j.append(n) ... sage: G = sage.plot.graphics.GraphicsArray(j) sage: G.show() # long time """ import networkx G = networkx.icosahedral_graph() pos = {} r1 = 5 r2 = 2 for i, v in enumerate([2, 8, 7, 11, 4, 6]): i = i + .5 pos[v] = (r1 * cos(i * pi / 3), r1 * sin(i * pi / 3)) for i, v in enumerate([1, 9, 0, 10, 5, 3]): i = i + .5 pos[v] = (r2 * cos(i * pi / 3), r2 * sin(i * pi / 3)) return graph.Graph(G, name="Icosahedron", pos=pos)
def test_intersection_array(self): b, c = nx.intersection_array(nx.cycle_graph(5)) assert_equal(b, [2, 1]) assert_equal(c, [1, 1]) b, c = nx.intersection_array(nx.dodecahedral_graph()) assert_equal(b, [3, 2, 1, 1, 1]) assert_equal(c, [1, 1, 1, 2, 3]) b, c = nx.intersection_array(nx.icosahedral_graph()) assert_equal(b, [5, 2, 1]) assert_equal(c, [1, 2, 5])
def test_intersection_array(self): b, c = nx.intersection_array(nx.cycle_graph(5)) assert b == [2, 1] assert c == [1, 1] b, c = nx.intersection_array(nx.dodecahedral_graph()) assert b == [3, 2, 1, 1, 1] assert c == [1, 1, 1, 2, 3] b, c = nx.intersection_array(nx.icosahedral_graph()) assert b == [5, 2, 1] assert c == [1, 2, 5]
def test_intersection_array(self): b,c=nx.intersection_array(nx.cycle_graph(5)) assert_equal(b,[2, 1]) assert_equal(c,[1, 1]) b,c=nx.intersection_array(nx.dodecahedral_graph()) assert_equal(b,[3, 2, 1, 1, 1]) assert_equal(c,[1, 1, 1, 2, 3]) b,c=nx.intersection_array(nx.icosahedral_graph()) assert_equal(b,[5, 2, 1]) assert_equal(c,[1, 2, 5])
def test_icosahedral_disjoint_paths(): G = nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) # edge disjoint paths edge_dpaths = list(nx.edge_disjoint_paths(G, 0, 6, **kwargs)) assert_true(are_edge_disjoint_paths(G, edge_dpaths), msg=msg.format(flow_func.__name__)) assert_equal(5, len(edge_dpaths), msg=msg.format(flow_func.__name__)) # node disjoint paths node_dpaths = list(nx.node_disjoint_paths(G, 0, 6, **kwargs)) assert_true(are_node_disjoint_paths(G, node_dpaths), msg=msg.format(flow_func.__name__)) assert_equal(5, len(node_dpaths), msg=msg.format(flow_func.__name__))
def test_is_distance_regular(self): assert_true(nx.is_distance_regular(nx.icosahedral_graph())) assert_true(nx.is_distance_regular(nx.petersen_graph())) assert_true(nx.is_distance_regular(nx.cubical_graph())) assert_true(nx.is_distance_regular(nx.complete_bipartite_graph(3, 3))) assert_true(nx.is_distance_regular(nx.tetrahedral_graph())) assert_true(nx.is_distance_regular(nx.dodecahedral_graph())) assert_true(nx.is_distance_regular(nx.pappus_graph())) assert_true(nx.is_distance_regular(nx.heawood_graph())) assert_true(nx.is_distance_regular(nx.cycle_graph(3))) # no distance regular assert_false(nx.is_distance_regular(nx.path_graph(4)))
def test_is_distance_regular(self): assert_true(nx.is_distance_regular(nx.icosahedral_graph())) assert_true(nx.is_distance_regular(nx.petersen_graph())) assert_true(nx.is_distance_regular(nx.cubical_graph())) assert_true(nx.is_distance_regular(nx.complete_bipartite_graph(3,3))) assert_true(nx.is_distance_regular(nx.tetrahedral_graph())) assert_true(nx.is_distance_regular(nx.dodecahedral_graph())) assert_true(nx.is_distance_regular(nx.pappus_graph())) assert_true(nx.is_distance_regular(nx.heawood_graph())) assert_true(nx.is_distance_regular(nx.cycle_graph(3))) # no distance regular assert_false(nx.is_distance_regular(nx.path_graph(4)))
def gen(): # predefined graphs in networkx # return nx.bull_graph() # 1-connected planar # return nx.chvatal_graph() # 4-connected non-planar # return nx.cubical_graph() # 3-connected planar # return nx.desargues_graph() # 3-connected non-planar # return nx.diamond_graph() # 2-connected planar # return nx.dodecahedral_graph() # 3-connected planar # return nx.frucht_graph() # 3-connected planar # return nx.heawood_graph() # 3-connected planar # return nx.house_graph() # 2-connected planar # return nx.house_x_graph() # 2-connected planar return nx.icosahedral_graph() # 5-connected planar
def test_icosahedral_disjoint_paths(): G = nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) errmsg = f"Assertion failed in function: {flow_func.__name__}" # edge disjoint paths edge_dpaths = list(nx.edge_disjoint_paths(G, 0, 6, **kwargs)) assert are_edge_disjoint_paths(G, edge_dpaths), errmsg assert 5 == len(edge_dpaths), errmsg # node disjoint paths node_dpaths = list(nx.node_disjoint_paths(G, 0, 6, **kwargs)) assert are_node_disjoint_paths(G, node_dpaths), errmsg assert 5 == len(node_dpaths), errmsg
def test_icosahedral_cutset(): G = nx.icosahedral_graph() # edge cuts edge_cut = nx.minimum_edge_cut(G) assert_equal(5, len(edge_cut)) H = G.copy() H.remove_edges_from(edge_cut) assert_false(nx.is_connected(H)) # node cuts node_cut = nx.minimum_node_cut(G) assert_equal(5, len(node_cut)) H = G.copy() H.remove_nodes_from(node_cut) assert_false(nx.is_connected(H))
def test_icosahedral_cutset(): G=nx.icosahedral_graph() # edge cuts edge_cut = nx.minimum_edge_cut(G) assert_equal(5, len(edge_cut)) H = G.copy() H.remove_edges_from(edge_cut) assert_false(nx.is_connected(H)) # node cuts node_cut = nx.minimum_node_cut(G) assert_equal(5,len(node_cut)) H = G.copy() H.remove_nodes_from(node_cut) assert_false(nx.is_connected(H))
def test_icosahedral_cutset(): G=nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) # edge cuts edge_cut = nx.minimum_edge_cut(G, **kwargs) assert_equal(5, len(edge_cut), msg=msg.format(flow_func.__name__)) H = G.copy() H.remove_edges_from(edge_cut) assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__)) # node cuts node_cut = nx.minimum_node_cut(G, **kwargs) assert_equal(5, len(node_cut), msg=msg.format(flow_func.__name__)) H = G.copy() H.remove_nodes_from(node_cut) assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
def test_icosahedral_cutset(): G = nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) # edge cuts edge_cut = nx.minimum_edge_cut(G, **kwargs) assert_equal(5, len(edge_cut), msg=msg.format(flow_func.__name__)) H = G.copy() H.remove_edges_from(edge_cut) assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__)) # node cuts node_cut = nx.minimum_node_cut(G, **kwargs) assert_equal(5, len(node_cut), msg=msg.format(flow_func.__name__)) H = G.copy() H.remove_nodes_from(node_cut) assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
def test_cutoff_disjoint_paths(): G = nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) for cutoff in [2, 4]: kwargs['cutoff'] = cutoff # edge disjoint paths edge_dpaths = list(nx.edge_disjoint_paths(G, 0, 6, **kwargs)) assert are_edge_disjoint_paths(G, edge_dpaths), msg.format( flow_func.__name__) assert cutoff == len(edge_dpaths), msg.format(flow_func.__name__) # node disjoint paths node_dpaths = list(nx.node_disjoint_paths(G, 0, 6, **kwargs)) assert are_node_disjoint_paths(G, node_dpaths), msg.format( flow_func.__name__) assert cutoff == len(node_dpaths), msg.format(flow_func.__name__)
def test_icosahedral_cutset(): G = nx.icosahedral_graph() for flow_func in flow_funcs: kwargs = dict(flow_func=flow_func) errmsg = f"Assertion failed in function: {flow_func.__name__}" # edge cuts edge_cut = nx.minimum_edge_cut(G, **kwargs) assert 5 == len(edge_cut), errmsg H = G.copy() H.remove_edges_from(edge_cut) assert not nx.is_connected(H), errmsg # node cuts node_cut = nx.minimum_node_cut(G, **kwargs) assert 5 == len(node_cut), errmsg H = G.copy() H.remove_nodes_from(node_cut) assert not nx.is_connected(H), errmsg
def platonic(n): # n must be 4, 6, 8, 12 or 20 # returns the matrix for sp2 platonic solid, with alpha = 0 and beta = -1 n_int = int(n) if n_int == 4: s = nx.tetrahedral_graph() elif n_int == 6: s = nx.cubical_graph() elif n_int == 8: s = nx.octahedral_graph() elif n_int == 12: s = nx.dodecahedral_graph() elif n_int == 20: s = nx.icosahedral_graph() else: print("n must be equal to 4, 6, 8, 12 or 20") M = -nx.adjacency_matrix(s) return M.todense()
def test_all_pairs_connectivity_icosahedral(self): G = nx.icosahedral_graph() C = nx.all_pairs_node_connectivity(G) assert_true(all(5 == C[u][v] for u, v in itertools.combinations(G, 2)))
seed = 123 # most used graphs G1 = nx.erdos_renyi_graph(n=24, p=0.3, seed=seed) # some cool graphs G2 = nx.star_graph(20) G3 = nx.path_graph(30) G4 = nx.petersen_graph() G5 = nx.dodecahedral_graph() G6 = nx.house_graph() G7 = nx.moebius_kantor_graph() G8 = nx.barabasi_albert_graph(5, 4) G9 = nx.heawood_graph() G10 = nx.icosahedral_graph() G11 = nx.sedgewick_maze_graph() G12 = nx.havel_hakimi_graph([1, 1]) G13 = nx.complete_graph(20) G14 = nx.bull_graph() G = G1 # choose a graph from the list gd.draw_custom(G) plt.show() #exact cut print("Time 'local_consistent_max_cut':" + str(gt.execution_time(mc.local_consistent_max_cut, 1, G))) print('Edges cut: ' + str(gc.cut_edges(G))) print('\n') print("Time 'lazy_local_consistent_max_cut':" + str(gt.execution_time(mc.lazy_local_consistent_max_cut, 1, G)))
def test_icosahedral(): G = nx.icosahedral_graph() assert_equal(5, nx.node_connectivity(G)) assert_equal(5, nx.edge_connectivity(G))
def test_properties_named_small_graphs(self): G = nx.bull_graph() assert G.number_of_nodes() == 5 assert G.number_of_edges() == 5 assert sorted(d for n, d in G.degree()) == [1, 1, 2, 3, 3] assert nx.diameter(G) == 3 assert nx.radius(G) == 2 G = nx.chvatal_graph() assert G.number_of_nodes() == 12 assert G.number_of_edges() == 24 assert list(d for n, d in G.degree()) == 12 * [4] assert nx.diameter(G) == 2 assert nx.radius(G) == 2 G = nx.cubical_graph() assert G.number_of_nodes() == 8 assert G.number_of_edges() == 12 assert list(d for n, d in G.degree()) == 8 * [3] assert nx.diameter(G) == 3 assert nx.radius(G) == 3 G = nx.desargues_graph() assert G.number_of_nodes() == 20 assert G.number_of_edges() == 30 assert list(d for n, d in G.degree()) == 20 * [3] G = nx.diamond_graph() assert G.number_of_nodes() == 4 assert sorted(d for n, d in G.degree()) == [2, 2, 3, 3] assert nx.diameter(G) == 2 assert nx.radius(G) == 1 G = nx.dodecahedral_graph() assert G.number_of_nodes() == 20 assert G.number_of_edges() == 30 assert list(d for n, d in G.degree()) == 20 * [3] assert nx.diameter(G) == 5 assert nx.radius(G) == 5 G = nx.frucht_graph() assert G.number_of_nodes() == 12 assert G.number_of_edges() == 18 assert list(d for n, d in G.degree()) == 12 * [3] assert nx.diameter(G) == 4 assert nx.radius(G) == 3 G = nx.heawood_graph() assert G.number_of_nodes() == 14 assert G.number_of_edges() == 21 assert list(d for n, d in G.degree()) == 14 * [3] assert nx.diameter(G) == 3 assert nx.radius(G) == 3 G = nx.hoffman_singleton_graph() assert G.number_of_nodes() == 50 assert G.number_of_edges() == 175 assert list(d for n, d in G.degree()) == 50 * [7] assert nx.diameter(G) == 2 assert nx.radius(G) == 2 G = nx.house_graph() assert G.number_of_nodes() == 5 assert G.number_of_edges() == 6 assert sorted(d for n, d in G.degree()) == [2, 2, 2, 3, 3] assert nx.diameter(G) == 2 assert nx.radius(G) == 2 G = nx.house_x_graph() assert G.number_of_nodes() == 5 assert G.number_of_edges() == 8 assert sorted(d for n, d in G.degree()) == [2, 3, 3, 4, 4] assert nx.diameter(G) == 2 assert nx.radius(G) == 1 G = nx.icosahedral_graph() assert G.number_of_nodes() == 12 assert G.number_of_edges() == 30 assert (list( d for n, d in G.degree()) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) assert nx.diameter(G) == 3 assert nx.radius(G) == 3 G = nx.krackhardt_kite_graph() assert G.number_of_nodes() == 10 assert G.number_of_edges() == 18 assert (sorted( d for n, d in G.degree()) == [1, 2, 3, 3, 3, 4, 4, 5, 5, 6]) G = nx.moebius_kantor_graph() assert G.number_of_nodes() == 16 assert G.number_of_edges() == 24 assert list(d for n, d in G.degree()) == 16 * [3] assert nx.diameter(G) == 4 G = nx.octahedral_graph() assert G.number_of_nodes() == 6 assert G.number_of_edges() == 12 assert list(d for n, d in G.degree()) == 6 * [4] assert nx.diameter(G) == 2 assert nx.radius(G) == 2 G = nx.pappus_graph() assert G.number_of_nodes() == 18 assert G.number_of_edges() == 27 assert list(d for n, d in G.degree()) == 18 * [3] assert nx.diameter(G) == 4 G = nx.petersen_graph() assert G.number_of_nodes() == 10 assert G.number_of_edges() == 15 assert list(d for n, d in G.degree()) == 10 * [3] assert nx.diameter(G) == 2 assert nx.radius(G) == 2 G = nx.sedgewick_maze_graph() assert G.number_of_nodes() == 8 assert G.number_of_edges() == 10 assert sorted(d for n, d in G.degree()) == [1, 2, 2, 2, 3, 3, 3, 4] G = nx.tetrahedral_graph() assert G.number_of_nodes() == 4 assert G.number_of_edges() == 6 assert list(d for n, d in G.degree()) == [3, 3, 3, 3] assert nx.diameter(G) == 1 assert nx.radius(G) == 1 G = nx.truncated_cube_graph() assert G.number_of_nodes() == 24 assert G.number_of_edges() == 36 assert list(d for n, d in G.degree()) == 24 * [3] G = nx.truncated_tetrahedron_graph() assert G.number_of_nodes() == 12 assert G.number_of_edges() == 18 assert list(d for n, d in G.degree()) == 12 * [3] G = nx.tutte_graph() assert G.number_of_nodes() == 46 assert G.number_of_edges() == 69 assert list(d for n, d in G.degree()) == 46 * [3] # Test create_using with directed or multigraphs on small graphs pytest.raises(nx.NetworkXError, nx.tutte_graph, create_using=nx.DiGraph) MG = nx.tutte_graph(create_using=nx.MultiGraph) assert sorted(MG.edges()) == sorted(G.edges())
def small_graphs(): print("Make small graph") G = nx.make_small_graph( ["adjacencylist", "C_4", 4, [[2, 4], [1, 3], [2, 4], [1, 3]]]) draw_graph(G) G = nx.make_small_graph( ["adjacencylist", "C_4", 4, [[2, 4], [3], [4], []]]) draw_graph(G) G = nx.make_small_graph( ["edgelist", "C_4", 4, [[1, 2], [3, 4], [2, 3], [4, 1]]]) draw_graph(G) print("LCF graph") G = nx.LCF_graph(6, [3, -3], 3) draw_graph(G) G = nx.LCF_graph(14, [5, -5], 7) draw_graph(G) print("Bull graph") G = nx.bull_graph() draw_graph(G) print("Chvátal graph") G = nx.chvatal_graph() draw_graph(G) print("Cubical graph") G = nx.cubical_graph() draw_graph(G) print("Desargues graph") G = nx.desargues_graph() draw_graph(G) print("Diamond graph") G = nx.diamond_graph() draw_graph(G) print("Dodechaedral graph") G = nx.dodecahedral_graph() draw_graph(G) print("Frucht graph") G = nx.frucht_graph() draw_graph(G) print("Heawood graph") G = nx.heawood_graph() draw_graph(G) print("House graph") G = nx.house_graph() draw_graph(G) print("House X graph") G = nx.house_x_graph() draw_graph(G) print("Icosahedral graph") G = nx.icosahedral_graph() draw_graph(G) print("Krackhardt kite graph") G = nx.krackhardt_kite_graph() draw_graph(G) print("Moebius kantor graph") G = nx.moebius_kantor_graph() draw_graph(G) print("Octahedral graph") G = nx.octahedral_graph() draw_graph(G) print("Pappus graph") G = nx.pappus_graph() draw_graph(G) print("Petersen graph") G = nx.petersen_graph() draw_graph(G) print("Sedgewick maze graph") G = nx.sedgewick_maze_graph() draw_graph(G) print("Tetrahedral graph") G = nx.tetrahedral_graph() draw_graph(G) print("Truncated cube graph") G = nx.truncated_cube_graph() draw_graph(G) print("Truncated tetrahedron graph") G = nx.truncated_tetrahedron_graph() draw_graph(G) print("Tutte graph") G = nx.tutte_graph() draw_graph(G)
import networkx as nx import matplotlib.pylab as plt from plot_multigraph import plot_multigraph graphs = [ ("bull", nx.bull_graph()), ("chvatal", nx.chvatal_graph()), ("cubical", nx.cubical_graph()), ("desargues", nx.desargues_graph()), ("diamond", nx.diamond_graph()), ("dodecahedral", nx.dodecahedral_graph()), ("frucht", nx.frucht_graph()), ("heawood", nx.heawood_graph()), ("house", nx.house_graph()), ("house_x", nx.house_x_graph()), ("icosahedral", nx.icosahedral_graph()), ("krackhardt_kite", nx.krackhardt_kite_graph()), ("moebius_kantor", nx.moebius_kantor_graph()), ("octahedral", nx.octahedral_graph()), ("pappus", nx.pappus_graph()), ("petersen", nx.petersen_graph()), ("sedgewick_maze", nx.sedgewick_maze_graph()), ("tetrahedral", nx.tetrahedral_graph()), ("truncated_cube", nx.truncated_cube_graph()), ("truncated_tetrahedron", nx.truncated_tetrahedron_graph()), ] plot_multigraph(graphs, 4, 5, node_size=50) plt.savefig('graphs/small.png')
del g[u][v]['visited'] if __name__ == '__main__': targets = { 'bull': nx.bull_graph(), # 1-connected planar 'chvatal': nx.chvatal_graph(), # 4-connected non-planar 'cubical': nx.cubical_graph(), # 3-connected planar 'desargues': nx.desargues_graph(), # 3-connected non-planar 'diamond': nx.diamond_graph(), # 2-connected planar 'dodecahedral': nx.dodecahedral_graph(), # 3-connected planar 'frucht': nx.frucht_graph(), # 3-connected planar 'heawood': nx.heawood_graph(), # 3-connected non-planar 'house': nx.house_graph(), # 2-connected planar 'house_x': nx.house_x_graph(), # 2-connected planar 'icosahedral': nx.icosahedral_graph(), # 5-connected planar 'krackhardt': nx.krackhardt_kite_graph(), # 1-connected planar 'moebius': nx.moebius_kantor_graph(), # non-planar 'octahedral': nx.octahedral_graph(), # 4-connected planar 'pappus': nx.pappus_graph(), # 3-connected non-planar 'petersen': nx.petersen_graph(), # 3-connected non-planar 'sedgewick': nx.sedgewick_maze_graph(), # 1-connected planar 'tetrahedral': nx.tetrahedral_graph(), # 3-connected planar 'truncated_cube': nx.truncated_cube_graph(), # 3-conn. planar 'truncated_tetrahedron': nx.truncated_tetrahedron_graph(), # 3-connected planar 'tutte': nx.tutte_graph() } # 3-connected planar for g_name, g in targets.items(): print g_name, is_planar(g)
def test_icosahedral(): G=nx.icosahedral_graph() assert_equal(5, approx.node_connectivity(G)) assert_equal(5, approx.node_connectivity(G, 0, 5))
def test_icosahedral(): G=nx.icosahedral_graph() assert_equal(5, nx.node_connectivity(G)) assert_equal(5, nx.edge_connectivity(G))
return list(approx.max_clique(graph)) # print selected_comm.number_of_nodes() # max_size_clique = nx.graph_clique_number(selected_comm) # print max_size_clique # for cl in nx.find_cliques(selected_comm): # if len(cl) == max_size_clique: # return cl # #print len(cl), cl #print nx.find_cliques(selected_comm) def choose_nodes_from_graph(graph, num_players, num_seeds, setup2): leftover = num_seeds - len(setup2) if leftover > 0: lst = setup2 + r.sample(graph.nodes(), leftover) else: lst = r.sample(setup2, num_seeds) return lst if __name__ == '__main__': g = nx.icosahedral_graph() setup = setup(g, 2, 2) print setup print choose_nodes_from_graph(g, 2, 2, setup) viewer.draw_graph(g) try: plt.show() except: plt.hide()
def test_icosahedral(): G = nx.icosahedral_graph() assert_equal(5, approx.node_connectivity(G)) assert_equal(5, approx.node_connectivity(G, 0, 5))
def test_icosahedral(): G = nx.icosahedral_graph() for flow_func in flow_funcs: errmsg = f"Assertion failed in function: {flow_func.__name__}" assert 5 == nx.node_connectivity(G, flow_func=flow_func), errmsg assert 5 == nx.edge_connectivity(G, flow_func=flow_func), errmsg
def test_icosahedral(self): expected = True actual = is_planar(nx.icosahedral_graph()) self.assertEqual(expected, actual)