List comprehension doesn't work or make any sense for creating a dictionary.
However, you can make a list of pairs, then turn it into a dictionary
as follows:
sage: dict( [(1,2), (3,[8,10])] )
{1: 2, 3: [8, 10]}
Here's an example like yours:
sage: dict( [(i,[i+1]) for i in [0..9]] + [(10,[0])] )
{0: [1], 1: [2], 2: [3], 3: [4], 4: [5], 5: [6], 6: [7], 7: [8], 8:
[9], 9: [10], 10: [0]}
> On another subject, is there anyway to tell if a graph is bipartite?
sage: g.is_bipartite()
Who would have thought?
> That
> would make problem #4 easy... I guess I could just make an interact for any
> ngraph and show that it's clique#=2 right? I know that a graph's chromatic
> number at least the size of the largest complete subgraph... but the
> chromatic number could be more than that right? How do i get around that?
>
> Is there a way to tell if a graph has a/an hamilton/eularian cycle/path?
g.eulerian_circuit()
Sage has no code for detecting hamiltonian paths.
William
>
>
> Thank you,
> Daniel Delamare
>
>
>
>
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org