from multi_graph import is_eulerian, eulerian_circuit

vertices = ["00", "01", "11", "10"]
edges = [[0, 1], [3, 2], [2, 3], [0, 1]]

print("Le graphe est eulérien :", is_eulerian(edges))

circuit = eulerian_circuit(edges)
print("Un circuit eulérien associé est :", circuit)

suite = ""

for mot in circuit:
    suite += vertices[mot][1]

print("Une suite de brujin : ", suite)
def test_eulerian_circuit_one_loop():
    assert eulerian_circuit(create_multi_graph(1, [[0, 0]])) == [0]
def test_eulerian_circuit():
    assert eulerian_circuit(create_multi_graph(
        2, [[0, 1], [1, 0], [0, 0]])) in ([0, 1, 0], [0, 0, 1], [1, 0, 0])
def test_eulerian_circuit_empty():
    assert eulerian_circuit([]) == []
Exemple #5
0
from multi_graph import is_eulerian, eulerian_circuit

multi_graph = { "00": ["00", "01"],
                "01": ["10", "11"],
                "11": ["11", "10"],
                "10": ["00", "01"],
               }

print("Le graphe est eulérien :", is_eulerian(multi_graph))

circuit = eulerian_circuit(multi_graph)
print("Un circuit eulérien associé est :", circuit)

suite = ""

for mot in circuit:
    suite += mot[1]

print("Une suite de brujin : ", suite)
def test_eulerian_circuit():
    assert eulerian_circuit(create_multi_graph([[1, 2], [2, 1],
                                                [1,
                                                 1]])) in ([1, 2,
                                                            1], [1, 1,
                                                                 2], [2, 1, 1])
def test_eulerian_circuit_one_loop():
    assert eulerian_circuit(create_multi_graph([[1, 1]])) == [1]
def test_eulerian_circuit_empty():
    assert eulerian_circuit(dict()) == []