The usual algorithm is this: Set each node to an initial value of +infinity, and then set the root node to 0. Repeatedly sweep through, setting each node to 1 plus the minimum of its neighbors. If nothing changed: stop. This takes as many sweeps as the longest path in the component containing the root node (namely, Ward), plus one. With a little extra bookkeeping you can avoid the extra sweep.

In practice you can't use a true +inf (assuming you're not using a language in which you can), so compromises are made. You can set the initial value to -1, NULL, NIL, MAX_INT, or other options. Each has its effect on the code. The cleanest code results from using an initial value of MAX_INT as an approximation to +inf.

Anyone not then connected to Ward via a PairProgramming path gets left with this initial value. Examining the algorithm suggests that this value should be +inf. This meshes nicely with the usual mathematical definition that the minimum of the empty set of numbers is +inf, just as the sum of the empty set of numbers is 0 - the initial value to which other values are added. In computing, a term that can't be computed is often preset to NULL, but the code is less clean.

You can also call it NIL, but null is more standard. Infinity is wrong, obviously. MAX_INT would be ok, though.

If you treat it as an IEEE 754 floating-point value, infinity is OK -- FredrikBreivald.

You need to say if it's a positive or negative infinity, though. Anyway, it's clearly a non-signalling NaN.

Positive infinity of course: it's the (unoriented) distance between two points and anything finite would be too small.

I would say such a person does not have a Ward number. Presumably, this is what is meant by saying 'null'. In a computer IMPLEMENTATION, one might well choose to give some value so that a compiler can cope with it without the programmer having to always incorporate code to deal with this case. Such a value might be NULL, INFINITY, MAX_INT, or NAN in a programming language which has one or more of these concepts. However, neither the definition of a Ward number nor the question refers to how one might represent it in a computer implemantation. The correct answer, it seems to me, is, as I said above, that such a person does not have a Ward number. If, on the other hand, you want an answer to the QUITE DIFFERENT question 'how would one represent such a person's Ward number in a computer implementation', then there are many different possibilities, and it is futile to argue as though there were one CORRECT answer. -- MichaelDavis

Mathematically the most consistent way to give a WardNumber to someone who has never practised PairProgramming or at least never done with anyone who is part of a path connecting back to WardCunningham would be - as noted above, +inf. This is because the WardNumber of a person P is the graph distance between WardCunningham and P in a graph where vertices correspond to people and two people are connected by an edge if they have practised PairProgramming together. If two points are in disconnected components in a graph then their graph distance is infinite. Reasoning: The definition of "distance" states that it's nonnegative, so it can't be less than zero. It can't be zero because that would mean the same point appears in both (disconnected) components - an absurdity. It can't be any finite number N greater than zero as that would imply that there is a path of length N by which one can get from the point in one component to the point in the other - again an absurdity.

You could argue that this means that there is no number that describes the distance between points in different disconnected components of a graph. But then you could also argue that the best insoles for leather boots are made of cheese. You could say that "there is no number" but that's as useful as saying "splunge"; an alternative would be something with existing semantics that would be consistent with its use in the current setting. The definition can be used to prove that there is no finite number that describes the distance - that whatever the distance is, it must be greater than any finite value. Fortunately, mathematicians long ago developed a concept to represent "something greater than any finite number" and they use it to define the graph distance between two disconnected points.

So an even more rigorous definition of WardNumber can be made:
Let G = {V,E} be a graph consisting of a set of vertices V representing people, and a set of edges between those vertices E such that for any two vertices u and v there is an edge in E iff the people represented by u and v have practised PairProgramming together.
Let a vertex w represent WardCunningham.
The WardNumber for any person P is defined as the path length between w and the vertex representing the person P.

There is absolutely no point in treating a person who has never practised PairProgramming differently from two people who have only ever practised PairProgramming with each other and no-one else. Or fifteen people who have practised PairProgramming among each other in some combination, but aren't connected to the same component as WardCunningham. Each of them is just as connected to WardCunningham as any of the others no matter how many people happen to share their component and that's all that matters to the definition.

Is there an entrepreneurial opportunity here? I would stick my neck out and offer my programming services to anyone wishing to acquire instant WardNumber 2 status... but then again, such an ostentatious act would probably reveal the fact that a WardNumber of 1 doesn't necessarily correlate to a presumed level of talent or genius. -- MichaelLeach

Ward is smart and a good programmer, but this WardNumber stuff is bordering on hero worship. I'm sure that Ward likes to be appreciated as much as the next guy, but this is just a little creepy. -- JimHollcraft

I agree. I'd put a stop to it except that I really do like programming with a lot of different people. I programmed a tv with a fella at oopsla just so we could say we'd programmed together. Do you suppose we should study the graph of people who have authored wiki pages together? -- WardCunningham

You should know better than that. CodeOwnership is not that good an idea, so surely someone as experienced as WardCunningham would avoid it just like the hero-worship he is stuck with on this page? -- SteveHolden

"Creepy-schmeepy. All in good fun..."
This is where we proclaim our WardNumbers:

Every wiki has parents; these are the wikis which directly inspired the foundation of that wiki

A wiki's wiki number is one greater than the lowest of its parents' wiki numbers

So the OusfgWiki? has a wiki number of 1, and the OxfordMathsWiki? has a wiki number of 2. A better example would be that MeatballWiki and WhyClublet have wiki numbers of 1, but I don't know of any children of theirs.

Note that this is different to the WardNumber in that it's more hierarchical, and less about the distance through a graph.