Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

test_analyse.py

Blame
  • Forked from Vuillemot Romain / INF-TC1
    Source project has a limited visibility.
    graph-get.py 562 B
    graph = { "a" : ["c"],
              "b" : ["c", "e"],
              "c" : ["a", "b", "d", "e"],
              "d" : ["c"],
              "e" : ["c", "b"],
              "f" : []
    }
    
    
    def genere_arretes(graph):
        edges = []
        for node in graph:
            for neighbour in graph[node]:
                edges.append((node, neighbour))
    
        return edges
    
    # Affiche les sommets
    print(list(graph.keys()))
    
    # Affiche les arrêtes
    print(genere_aretes(graph))
    
    # >>> [('a', 'c'), ('c', 'a'), ('c', 'b'), ('c', 'd'), ('c', 'e'), 
    #    ('b', 'c'), ('b', 'e'), ('e', 'c'), ('e', 'b'), ('d', 'c')]