Ask Your Question

Revision history [back]

If G is your graph, then G.to_dictionary() does what you're asking for, I believe.

If G is your graph, then G.to_dictionary() does what you're asking for, I believe.

sage: d = {0: [1, 5, 7, 8, 11],
....:  1: [0, 2, 5, 6, 8],
....:  2: [1, 3, 6, 8, 9],
....:  3: [2, 4, 6, 9, 10],
....:  4: [3, 5, 6, 10, 11],
....:  5: [0, 1, 4, 6, 11],
....:  6: [1, 2, 3, 4, 5],
....:  7: [0, 8, 9, 10, 11],
....:  8: [0, 1, 2, 7, 9],
....:  9: [2, 3, 7, 8, 10],
....:  10: [3, 4, 7, 9, 11],
....:  11: [0, 4, 5, 7, 10]}
sage: G = Graph(d)
sage: G.to_dictionary()
{0: [1, 5, 7, 8, 11],
 1: [0, 2, 5, 6, 8],
 2: [1, 3, 6, 8, 9],
 3: [2, 4, 6, 9, 10],
 4: [3, 5, 6, 10, 11],
 5: [0, 1, 4, 6, 11],
 6: [1, 2, 3, 4, 5],
 7: [0, 8, 9, 10, 11],
 8: [0, 1, 2, 7, 9],
 9: [2, 3, 7, 8, 10],
 10: [3, 4, 7, 9, 11],
 11: [0, 4, 5, 7, 10]}
sage: G.to_dictionary() == d
True