1 | initial version |

Here is one (not so elegant) possibility

```
sage: J = IndependentSets(graphs.CycleGraph(4))
sage: t = polygen(ZZ)
sage: F = 0
sage: for x in J:
....: N = len(set().union(G.neighbor_iterator(v) for v in x))
....: F += t^N
sage: F
2*x^2 + 4*x + 1
```

It is not so elegant because it constructs the explicit list of neighbors.

2 | No.2 Revision |

Here is one (not so elegant) possibility

```
sage: J = IndependentSets(graphs.CycleGraph(4))
sage: t =
```~~polygen(ZZ)
~~polygen(ZZ, 't')
sage: F = 0
sage: for x in J:
....: N = ~~len(set().union(G.neighbor_iterator(v) ~~len(set().union(*[G.neighbor_iterator(v) for v in ~~x))
~~x]))
....: F += t^N
sage: F
~~2*x^2 + 4*x ~~6t^2 + 1

It is not so elegant because it constructs the explicit list of neighbors.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.