# Infinite graphs in sage

I wonder if there is some sort of lazy evaluation in sage. Assume I want to answer a finite question about some infinite structure that can be represented using finite data. As a contrived example: Consider the graph that has as its vertices the natural numbers and an edge (i,j) whenever i divides j. Is there an elegant (lazy evaluation) way to represent this? For instance I could think of a function that investigates the sizes of connected components below the first 500 primes or such.

I don't see why not. That's what things like yield statements and so forth are about. I supposed you'd need to use a Python class to do this - make a class instantiating this graph. But you *would* have to use some Python fu to do this, I suspect, if I understand what you mean by "lazy evaluation". I may not, and my apologies if I've totally misinterpreted your question.

Alright, thanks. What I was thinking of is too much to ask for: Let the work of implementing all the logic of local exploration of the data be done by the compiler. There are theoretical reasons for this being impossible in python, for instance you need strict static typing (like in Haskell).