def test_franklin(self):
     """ 12-vertex cubic graph: non-planar but hamiltonian """
     expected = False
     actual = is_planar(nx.LCF_graph(12, [5, -5], 6))
     self.assertEqual(expected, actual)
     actual = is_planar(nx.LCF_graph(12, [-5, -3, 3, 5], 3))
     self.assertEqual(expected, actual)
Esempio n. 2
0
def gen():
    g = nx.LCF_graph(20, [1, 3, 14], 5)
    pairs = [(0, 12), (1, 5), (1, 19), (2, 11), (3, 4),
             (3, 9), (3, 18), (6, 15), (10, 14)]
    print pairs
    costs = [1] * nx.number_of_edges(g) * 2
    return (g, costs, pairs)
 def test_harries(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(70, [
             -29, -19, -13, 13, 21, -27, 27, 33, -13, 13, 19, -21, -33, 29
         ], 5))
     self.assertEqual(expected, actual)
Esempio n. 4
0
def gen():
    g1 = nx.frucht_graph()
    g2 = nx.LCF_graph(12, [-5, -2, -4, 2, 5, -2, 2, 5, -2, -5, 4, 2], 1)
#    print(nx.is_isomorphic(g1, g2))
#    g1 = nx.cubical_graph()
#    g2 = nx.LCF_graph(8, [3, -3], 4)
    return g1, g2
 def test_tutte_12_cage(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(126, [
             17, 27, -13, -59, -35, 35, -11, 13, -53, 53, -27, 21, 57, 11,
             -21, -57, 59, -17
         ], 7))
     self.assertEqual(expected, actual)
Esempio n. 6
0
def gen(k):
    g = nx.LCF_graph(20, [1, 3, 14], 5)
    for u, v in g.edges_iter():
        g[u][v]['cost'] = 2

    random.seed(3)
    srcs = random.sample(range(g.number_of_nodes()), k)

    return (g, srcs)
    def test__LCF_graph(self):
        # If n<=0, then return the null_graph
        G = nx.LCF_graph(-10, [1, 2], 100)
        assert is_isomorphic(G, null)
        G = nx.LCF_graph(0, [1, 2], 3)
        assert is_isomorphic(G, null)
        G = nx.LCF_graph(0, [1, 2], 10)
        assert is_isomorphic(G, null)

        # Test that LCF(n,[],0) == cycle_graph(n)
        for a, b, c in [(5, [], 0), (10, [], 0), (5, [], 1), (10, [], 10)]:
            G = nx.LCF_graph(a, b, c)
            assert is_isomorphic(G, nx.cycle_graph(a))

        # Generate the utility graph K_{3,3}
        G = nx.LCF_graph(6, [3, -3], 3)
        utility_graph = nx.complete_bipartite_graph(3, 3)
        assert is_isomorphic(G, utility_graph)
 def test_Ljubljana(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(26, [
             47, -23, -31, 39, 25, -21, -31, -41, 25, 15, 29, -41, -19, 15,
             -49, 33, 39, -35, -21, 17, -33, 49, 41, 31, -15, -29, 41, 31,
             -15, -25, 21, 31, -51, -25, 23, 9, -17, 51, 35, -29, 21, -51,
             -39, 33, -9, -51, 51, -47, -33, 19, 51, -21, 29, 21, -31, -39
         ], 2))
     self.assertEqual(expected, actual)
 def test_harries_wong(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(70, [
             9, 25, 31, -17, 17, 33, 9, -29, -15, -9, 9, 25, -25, 29, 17,
             -9, 9, -27, 35, -9, 9, -17, 21, 27, -29, -9, -25, 13, 19, -9,
             -33, -17, 19, -31, 27, 11, -25, 29, -33, 13, -13, 21, -29, -21,
             25, 9, -11, -19, 29, 9, -27, -19, -13, -35, -9, 9, 17, 25, -9,
             9, 27, -27, -21, 15, -9, 29, -29, 33, -9, -25
         ], 1))
     self.assertEqual(expected, actual)
 def test_balaban_10(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(70, [
             68, -25, -18, 29, 13, 35, -13, -29, 19, 25, 9, -29, 29, 17, 33,
             21, 9, -13, -31, -9, 25, 17, 9, -31, 27, -9, 17, -19, -29, 27,
             -17, -9, -29, 33, -25, 25, -21, 17, -17, 29, 35, -29, 17, -17,
             21, -25, 25, -33, 29, 9, 17, -27, 29, 19, -17, 9, -27, 31, -9,
             -17, -25, 9, 31, 13, -9, -21, -33, -17, -29, 29
         ], 1))
     self.assertEqual(expected, actual)
 def test_biggs_smith(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(102, [
             16, 24, -38, 17, 34, 48, -19, 41, -35, 47, -20, 34, -36, 21,
             14, 48, -16, -36, -43, 28, -17, 21, 29, -43, 46, -24, 28, -38,
             -14, -50, -45, 21, 8, 27, -21, 20, -37, 39, -34, -44, -8, 38,
             -21, 25, 15, -34, 18, -28, -41, 36, 8, -29, -21, -48, -28, -20,
             -47, 14, -8, -15, -27, 38, 24, -48, -18, 25, 38, 31, -25, 24,
             -46, -14, 28, 11, 21, 35, -39, 43, 36, -38, 14, 50, 43, 36,
             -11, -36, -24, 45, 8, 19, -25, 38, 20, -24, -14, -21, -8, 44,
             -31, -38, -28, 37
         ], 1))
     self.assertEqual(expected, actual)
 def test_balaban_11(self):
     expected = False
     actual = is_planar(
         nx.LCF_graph(112, [
             44, 26, -47, -15, 35, -39, 11, -27, 38, -37, 43, 14, 28, 51,
             -29, -16, 41, -11, -26, 15, 22, -51, -35, 36, 52, -14, -33,
             -26, -46, 52, 26, 16, 43, 33, -15, 17, -53, 23, -42, -35, -28,
             30, -22, 45, -44, 16, -38, -16, 50, -55, 20, 28, -17, -43, 47,
             34, -26, -41, 11, -36, -23, -16, 41, 17, -51, 26, -33, 47, 17,
             -11, -20, -30, 21, 29, 36, -43, -52, 10, 39, -28, -17, -52, 51,
             26, 37, -17, 10, -10, -45, -34, 17, -26, 27, -21, 46, 53, -10,
             29, -50, 35, 15, -47, -29, -41, 26, 33, 55, -17, 42, -26, -36,
             16
         ], 1))
     self.assertEqual(expected, actual)
Esempio n. 13
0
def gen():
    g1 = nx.frucht_graph()
    g2 = nx.LCF_graph(12, [-5, -2, -4, 2, 5, -2, 2, 5, -2, -5, 4, 2], 1)
    return g1, g2
 def test_tutte_coxeter(self):
     expected = False
     actual = is_planar(nx.LCF_graph(26, [-13, -9, 7, -7, 9, 13], 5))
     self.assertEqual(expected, actual)
 def test_f26a(self):
     expected = False
     actual = is_planar(nx.LCF_graph(26, [-7, 7], 13))
     self.assertEqual(expected, actual)
 def test_naruru(self):
     expected = False
     actual = is_planar(nx.LCF_graph(24, [5, -9, 7, -7, 9, -5], 4))
     self.assertEqual(expected, actual)
 def test_bidiakis_cube(self):
     expected = True
     actual = is_planar(nx.LCF_graph(12, [6, 4, -4], 4))
     self.assertEqual(expected, actual)
 def test_mcgee(self):
     """ 24-vertex 7-cage graph: non-planar """
     expected = False
     actual = is_planar(nx.LCF_graph(24, [-12, 7, -7], 8))
     self.assertEqual(expected, actual)
Esempio n. 19
0
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)
 def test_gray(self):
     expected = False
     actual = is_planar(nx.LCF_graph(54, [-25, 7, -7, 13, -13, 25], 9))
     self.assertEqual(expected, actual)
 def test_dyck(self):
     expected = False
     actual = is_planar(nx.LCF_graph(32, [-13, 5, -5, 13], 8))
     self.assertEqual(expected, actual)
 def test_levi(self):
     """ 30-vertex incidence graph: non-planar """
     expected = False
     actual = is_planar(nx.LCF_graph(30, [-13, -9, 7, -7, 9, 13], 5))
     self.assertEqual(expected, actual)
Esempio n. 23
0
def gen():
    G = nx.LCF_graph(20, [1, 3, 14], 5)
    for i, j in G.edges():
        G[i][j]['weight'] = 2
    return G
 def test_utility(self):
     expected = False
     actual = is_planar(nx.LCF_graph(6, [3, -3], 3))
     self.assertEqual(expected, actual)
Esempio n. 25
0
import picos as pic
import networkx as nx

#number of nodes
N = 20

#Generate a graph with LCF notation (you can change the values below to obtain another graph!)
#We use this deterministic generator in order to have a constant inuput for doctest.
G = nx.LCF_graph(N, [1, 3, 14], 5)
G = nx.DiGraph(G)  #edges are bidirected

#generate edge capacities
c = {}
for i, e in enumerate(G.edges()):
    c[e] = ((-2)**i) % 17  #an arbitrary sequence of numbers

#-------------#
#   min cut   #
#-------------#

mincut = pic.Problem()

#source and sink nodes
s = 16
t = 10

#convert the capacities as a picos expression
cc = pic.new_param('c', c)

#cut variable
d = {}
 def test_foster(self):
     expected = False
     actual = is_planar(nx.LCF_graph(90, [17, -9, 37, -37, 9, -17], 15))
     self.assertEqual(expected, actual)