*(This is a follow-up to my previous question [Can every finite graph be represented by an arithmetic sequence of natural numbers?](https://mathoverflow.net/questions/17875/can-every-finite-graph-be-represented-by-an-arithmetic-sequence-of-natural-number))*


Since it is obviously false that every finite graph can be represented by an *arithmetic* sequence (with an edge between two vertices/numbers $n\_i, n\_j$ iff GCD$(n\_i, n\_j)>1$) I'd like to reformulate my question:


Consider a family $F$ of parametrized computable functions $\lbrace f\_{\alpha}:\mathbb{N}^k\mapsto\mathbb{N}\rbrace\_{\alpha}$ with $\alpha \in \mathbb{N}^{n}$ for some $k,n \in \mathbb{N}$.


A sequence $(n\_1,....,n\_k,n\_{k+1},...,n\_{k+l})$ is an $F$-sequence if $n\_{i+k} = f\_\alpha(n\_i,n\_{i+1},...,n\_{i+k-1})$ for some fixed $f\_\alpha \in F$.


An arithmetic sequence is an $F$-sequence for $F = \lbrace f\_\alpha(n) = n + \alpha\rbrace\_{\alpha \in \mathbb{N}}$.



> 
> **Question:** Is there a family $F$ of functions $f\_{\alpha}:\mathbb{N}^k\mapsto\mathbb{N}$ (as above) such that every graph on $n > k$ nodes can be represented by an $F$-sequence
>  such that $n\_i$ and $n\_j$ are joined by an edge iff $n\_i \neq n\_j$ and GCD$(n\_i, n\_j) > 1$
> 
> 
> 


My first question was genuinely "first-order" and admitted a straight-forward "first-order" answer (even though negative). *This* question is genuinely "second-order" and furthermore existential and probably doesn't admit a straight-forward definite answer. Sorry for that (and I tagged it as a "soft question"). But maybe someone can give a hint how to try to attack it?



Can every finite graph be represented by one prescribed sequence of natural numbers?
The answer is "yes": there is such a family of $F$ functions. In fact, a single computable function, acting on a single integer argument, suffices. We may do this by storing essentially complete information about the graph, and about the process of "constructing" the graph $G$ (that is, the process of computing suitable integers $n\_j$ representing vertices $v\_j \in V(G)$), in the integers $n\_j$ themselves.


**Edit:** *My original answer contained an error in which the correct adjacency relations were not properly produced. I correct this below, and have taken the opportunity to make other minor revisions.*


We may specify a graph on $n$ vertices using a single integer by a number of different methods, such as using binary representation to use an $n^2$ bit integer to give the adjacency matrix of the graph. (The leading 1 represents an entry in the diagonal, which may serve to define the size of the graph without denoting any edges if we consider only simple graphs.) Denote this binary representation of the graph $G$ by $g \in \mathbb N$. We compute the integers $n\_j$ by carrying $g$ as the exponents of different primes, and using other prime factors to "induce" adjacency between the integers representing different integers.


Let $p\_j$ denote the $j^{\textrm{th}}$ prime, with $p\_1 = 2$, $p\_2 = 3$, etc. We define
$$ N\_j = p\_j^g $$
which will act as a "label" of sorts for our vertices; each vertex $v\_j \in V(G)$ (for an arbitrary ordering of the vertices) will be represented by an integer which is divisible by the prime $p\_j$, but not by any other prime $p\_k$ for $1 \le k \le n$. At the same time, this labelling carries with it an entire description of the graph, as well as the vertex ordering (in this case, given by the ordering of the rows/columns of the adjacency matrix of $G$). The smallest prime factor of the integer $n\_j$ corresponding to the vertex $v\_j$ will indicate which vertex it is in the order, and carry a complete description of the graph $G$.


We may induce adjacency among the vertices by giving them appropriate common prime factors. A simple way to do this is to associate a prime to each edge, and give any two vertices belonging to a common edge the corresponding prime factor. (Vertices which do not share an edge in common will have no common prime factors, and thus be coprime.) We order the possible edges by considering the lexicographic ordering on all ordered pairs $(v\_j, v\_k)$ such that $v\_j < v\_k$: thus the possible edge $v\_j v\_k$ (for $j < k$) will be edge number $\varepsilon(j,k) = \binom{k-1}{2} + j$ in the enumeration. More generally, we may define
$$ \varepsilon(j,k) = \binom{\max \{j,k\} - 1}{2} + \min \{j,k\} .$$
We may represent the adjacency of two vertices $v\_j, v\_k$ by giving their corresponding integers $n\_j, n\_k$ a common prime factor, namely the prime $p\_{n+\varepsilon(j,k)}$. The exponents of the primes $p\_{n+1}$ through $p\_{n+\binom{n}{2}}$ in the integers $n\_j$ then form the incidence matrix of edges to vertices in $G$.


Thus, we may let $F(x)$ be the function which computes the following:


1. Determine the smallest prime $p\_{j-1} \mid x$, and the corresponding index $j$.
- Determine the exponent, $g$, of the largest power of $p\_{j-1}$ which divides $x$.
- Extract from $g$ complete information about the graph $G$, including its size $n$.
- Determine the next largest prime $p\_j > p\_{j-1}$.
- Compute $N\_j = p\_j^g$.
- Compute $M\_j = p\_{n+j}$.
- For each $1 \le k \le n$, $k \ne j$:
	* Compute $\varepsilon(j,k)$.
	* If $v\_j$ is adjacent to $v\_k$ in $G$, set $M\_j \leftarrow M\_j p\_{n+\varepsilon(j,k)}$.- Return $y = N\_j M\_j$.


To produce an appropriate $F$-sequence which represents $G$, it then suffices to compute $n\_1$, which is
$$ n\_1 = p\_1^g \prod\_{k \ne j} {p\_{n+\varepsilon(j,k)}}^{A\_{j,k}} , $$
where $A$ is the adjacency matrix of $G$; this suffices to iteratively produce the other integers $n\_k$ using $F$.


The above can be readily extended to accommodate hypergraphs (allow more than two vertices per 'edge') and other generalizations; one only needs to choose a suitable representation, and store it in an integer in some way which can be extracted. These are standard tricks in computability theory; we are just adapting Godel numbering for a special purpose in this case.


If you want an "interesting" way of representing graphs by models in integer sequences, which does not just amount to packing and unpacking of data structures in the integers, you're going to have to impose some non-trivial bounds --- on the integer sizes, on the computational efficiency of the procedure, etc. --- and then, you will almost certainly have to be satisfied with obtaining only some special class of graphs. But that special class may still be an interesting one, if your computational constraints are well-chosen. 


