# How many nodes in the network?

I don't actually have a solution in mind for these, but it seemed puzzly enough to bring to the table. Seems as though someone must have come up with this before, but if so, I couldn't find it when I looked (or perhaps recognize it when I found it ^_^). Despite my language in framing the problem, I'm hoping for physics/biology-inspired solutions, so simpler methods and low 'memory' use are preferred over low-cycle-count-at-any-cost.

A finite network has an unknown number of identically programmed deterministic nodes (so no unique id to lead a D/BFS, and RNG can't break symmetry). Each cycle, a node can transmit a single number, received only by its immediate neighbors. How efficiently (if at all) can every node be informed of the total number of nodes in the network? Presumably all nodes initially broadcast '1', and therefore learn how many neighbors each has...?

• 1A. The same number is broadcast to all neighbors, and a node only receives the sum of all signals from its neighbors.

• 1B. Still broadcasting, but now each node knows the multiset of numbers transmitted by its neighbors, but not which sent which.

• 1C. Still broadcasting, but now each node can distinguish which neighbor sent which signal.

• 2ABC. As above, but now nodes can send different signals to different neighbors.

• Welcome to Puzzling SE! Hope you stay! – NL628 Apr 7 '18 at 7:05
• Sounds like an interesting problem, but I wonder about each node being programmed identically or at least not having a unique idenfier tag - could we allow each node to have a different identifier number and yet be programmed in the same way - I see you discount it in the problem. Without some uniqueness I worry about how a node can effectively receive a message back from itself without being confused by 'noise' from other nodes.---- If this makes the problem too easy then maybe each node can have a non-sequential identifier like 3, 129, 75, etc – tom Apr 7 '18 at 9:12
• . -- or maybe the solution is to have some way of building sequential unique identifiers. – tom Apr 7 '18 at 9:16
• Thanks for the welcome! I chose puzzling over math (or CS) due to the whimsical nature of the constraints. In any pragmatically-designed system, it'd be silly for the engineers not to build in capacity for unique ID and Goedel-numbering (as already-mentioned below), but I'm hoping for something like a reaction-diffusion mechanism that would allow (say) unusually clever bacteria to know the size of their colony asymptotically exactly. – Zomulgustar Apr 7 '18 at 13:25
• 1A sounds a lot like how biological neural networks work. As a whole, (assuming sufficient connectivity and node count) such a network can of course gain almost any knowledge by achieving sentience; I'm not certain it's the number one most efficient approach though :-) – Bass Apr 8 '18 at 21:19

The following applies to questions 1ABC:

I do not think it is possible. Consider cycle graphs, i.e. nodes connected in a long loop, so each node has two neighbours. Suppose you have two such graphs, of different sizes. At each stage, the nodes in both graphs will all send the same number, and then receive the same number(s), because they are locally all exactly the same. They all have the same inputs, so will produce the same outputs, and at no point will the node be able to determine in which cycle graph it lies.

Remark that may help for questions 2ABC:

Being able to send only one number is not a restriction. By using Gödel encoding you can essentially send any list of numbers, and so encode any amount of information in the message you want.

I'm not so sure about the setup however. Can each node distinguish between neighbours only once they have received different replies? For example in a cycle graph, can the nodes send different messages to their neighbours in the very first step, and if so, which message goes in which direction? If they can only send different messages in response to having received different messages, then the argument in #1 applies here too, and it is not possible.

• I would wonder about binary encoding, which seems less complicated than the (interesting) Goedel encoding – tom Apr 7 '18 at 9:08
• @tom Sure, binary encoding (e.g. ASCII or BCD) works fine here too. You just need a fixed alphabet so that you know how many bits each letter takes up, or more generally you can use a base $n$ encoding for an alphabet of $n$ symbols. To send more than one word, you need to include a separator symbol (a 'space') in the alphabet too. Gödel encoding's alphabet is infinitely large - any number is encoded as one symbol, without the need for a separator. I think Gödel also needed certain arithmetic properties for his encoding which we don't here. – Jaap Scherphuis Apr 7 '18 at 9:42
• Suppose, after the initial 'ping', that every node hears the 'direction' that different otherwise-identical transmissions come from well enough – Zomulgustar Apr 7 '18 at 13:30
• So apparently comments can only be edited for 5 minutes :p Suppose, after the initial 'ping', that every node hears the 'direction' that different otherwise-identical transmissions come from relative to some 'true north' exactly well enough to receive and transmit ordered tuples rather than multisets. (So they recognize a 'first neighbor', 'second neighbor', etc. but can't 'transmit the angle between the previous two neighbors'. – Zomulgustar Apr 7 '18 at 13:36
• You're quite right about Goedel numbers of course..I was just hoping to avoid their ilk. .I'm not entirely convinced that the broadcasting problems are impossible in principle, but your argument clearly demonstrates the necessity of such 'tricks'. No time to flesh out the idea now (or see if it falls to your argument, just tossing it out before i forget ) but an aperiodic sequence passed + summed might make different patterns going around cycles of different lengths... – Zomulgustar Apr 7 '18 at 13:42