Skip to content
Snippets Groups Projects
Select Git revision
  • 00beb9f4639487b70b8c765166b4c3d537be18e4
  • main default protected
  • master
3 results

mlp.py

Blame
  • 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')]