It's rush hour in the city. Downtown crosswalks turn a blur of suits and backpacks as working Auckland shuffles from cubicle to carpark.
The pedestrians cut through each other in six loose directions and the corners of Queen St and Victoria St clog with people.
Forty-five minutes earlier, the footpaths were an untidy scattering of students and tourists weaving among each other across the width of the pavements.
Now, at 5.10pm, the same stretches of street have become human highways - one stream keeping to the left and walking toward Britomart, the other mass heading uptown.
Few Aucklanders realise it, but, just like bees, they're part of a swarm, subconsciously attuned to the hidden quirks of their own hive.
They like to keep to the left, and when they come face-to-face, they'll also pass on the left.
Because of this, an Aucklander in London will often find themselves in pavement stand-offs with locals, who prefer to pass each other on the right.
Where most of us just see a typical scramble of bodies, Professor Shaun Hendy, one of our best-known minds, sees a pattern.
Specifically, patterns that break what's called left-right symmetry, and which people living near each other follow because they've made collective decisions we're only just beginning to understand.
These clever natural designs, which exist everywhere around us, are what physicists like Hendy know as complex systems.
They're now using them to solve some of society's biggest challenges.
Hendy finds it particularly amusing how Wellingtonians returning library books typically found themselves barred entry by automatic doors that expected them to exit rather than to enter. Apparently, the designers of the city's library, unaware of Kiwis' preference for walking on the left, put the entrance on the right and the exit on the left.
"It's tempting to think that our choice might have something to do with our traffic laws, but of course the Brits drive on the left just like we do, yet choose to pass on the right, not the left," he tells the Weekend Herald. "Instead, this type of pattern seems to be spontaneous, and it emerges from the collective choices of a large group of people - it's a perfect illustration of how more is different."
Crowd behaviour can be good and bad - after a Bledisloe Cup match, the rivers of humanity flowing from Eden Park will whisk us out of the stadium via the most efficient routes. At Sylvia Park on Christmas Eve, however, the car parking levels closest to the entrances will always be crammed with circling vehicles.
It's not just people we observe these patterns in - organisms in ecosystems and assemblies of molecules and atoms can show collective behaviour that isn't just the aggregate of a whole lot of independent, individual actions or decisions.
Every time we Google something, for example, we make use of the science of complex systems, because the search engine exploits the fact that people tend to create links to the most useful web pages.
Realising that the web is more than just the sum of its individual pages, Google finds you the page linked to by the most linked-to webpages, rather than the page with the most links to it.
This complex systems approach enables Google's search to process 40,000 searches per second and 3.5 billion each day.
"Perhaps the most intriguing aspect of complex systems is that we see behaviours in crowds, the stock market and traffic flows that also occur in collections of molecules," Hendy says.
"Some properties of natural ecosystems are even seen in economies. Why do these very different and very complex systems behave in similar ways?
"This is very exciting for a scientist as it suggests that there might be some underlying general rules that underlie complex systems."
Welcome to the whiteboards of Te Punaha Matatini, a newly created Centre of Research Excellence, which Hendy heads from a small office in the sixth level of the University of Auckland's Building 303.
Hendy reckons the idea that there might be a "science of complex systems" took hold at some point in the early 1970s.
Around that time, an American physicist named Philip Warren Anderson penned an article titled More Is Different, in which he asked whether the economy or society could be understood by studying atoms and molecules.
"Society is made of people, people are made of cells, and cells are made of molecules, so why not?" Hendy says.
"Anderson said ... collective behaviour couldn't be fully understood by looking at individual elements of a system - hence more is different."
One starting point was mathematical techniques developed by physicists that provide good descriptions of the collective behaviour of physical systems, such as solids and liquids.
Researchers can combine the maths to big sets of data describing the economy or other systems. Another was to take concepts from ecology and apply them to the economy.
For instance, Hendy pointed out, ecologists already know that biologically diverse ecosystems are more resilient to environmental change, so you could ask whether diverse economies also cope better.
Some the key ideas concerning ecological networks have been developed in New Zealand, as some of the world's leading ecologists work here, perhaps thanks to our unique flora and fauna.
At Te Punaha Matatini, researchers from all branches of science - but particularly from physics, ecology, economics, mathematics, and social science - are now being brought together to use the approach on the big issues facing the country.
One project, led by Dr Alexei Drummond, will analyse the DNA of the flu virus to track how different strains spread through the population, before reconciling that data with information about how people move into or around the country using cellphone location data.
"If lots of people travel from Sydney to Wellington for a Bledisloe Cup match, for instance, does this increase the likelihood that Australian strains of flu will spread to New Zealand?" Hendy says.
"This might be useful for designing vaccination programmes that protect against particular strains of the flu.
"We also have some early stage projects applying complex systems science to sports, to try to analyse team tactics in new ways, in soil science, where we are thinking about how to define a terroir for Kiwi winegrowers, and even in archaeology to try to understand how ancient societies grow and develop.
"Other researchers are using complex systems science to predict crime, detect fraud, and to improve healthcare."
As a society, he said, it was important we understood that we could make unconscious collective decisions, such as the side of the footpath that we walk on, as well those we are conscious of, like whether or not we need a new flag.
"For instance, the dynamics of pedestrians can not only be annoying at times but also dangerous if they are not incorporated into the design of our public spaces," he said.
"This shouldn't challenge our sense of individuality, but rather serve as a reminder that we share our lives with many other people, and that the decisions we make affect other people at the same time as their decisions affect us."
What big data can tell us about...
We know the flu spreads through networks of people who come into contact - but what if we could use big data to gain an accurate picture of which cities different strains might travel between?
Te Punaha Matatini principal investigator Dr Alexei Drummond will analyse the DNA of the flu virus to track its spread, and then compare it against cellphone data showing how people move into or around the country. The resulting data may be useful for designing vaccination programmes that protect against particular strains of the flu.
Te Punaha Matatini director Dr Shaun Hendy says the researchers will be using anonymous data sets, also used by companies for marketing.
Because laws almost always refer to other laws, we can build a corresponding network of New Zealand legislation, Hendy says.
PhD student Neda Sakhaee, along with Te Punaha Matatini associate investigator Mark Wilson, is looking at this network of laws in the same way as Google looks at web pages.
"In the same way that Google finds the most useful webpages, we can find the most important laws so if they were changed, how much would they affect the rest of the legal system," Hendy says. "We can also look at whether our laws are more complex than the laws of other countries - Neda is working on a comparison between New Zealand law to Canadian law. Initial results suggest that New Zealand law may be more complex."
University of Canterbury academic Dr Alex James, one of Te Punaha Matatini's deputy directors, is leading a project to make crowd-sourced ecological observations - that is, observations collected by the general public, like the great kereru count - as reliable as the type of data collected by ecologists.
"To do this, we will need to understand a lot more about how people are making their observations - if 50 people saw a kereru in Albert Park on their lunch break, were there 50 kereru, just one, or something in between?" Hendy says.
"If we can do this then we will be able to help local communities monitor the health of their own local environment."
A study led by University of Auckland researcher Dr Dion O'Neale investigated the relationship between the mix of technological speciality in more than 4000 places and cities, and the novelty of the patented products that sprouted from them.
It found that the rate of innovation didn't necessarily reflect the number of researchers in a particular place - and having a wide range of different work going on was often the real difference.
"We know that the hotspots for new ideas coincide with places where people are well-connected, which is generally in big cities," Hendy says. "But diversity matters too - a city where everybody knew and worked on the same things would not be very innovative."
In New Zealand, Auckland is both the most technologically diverse and well-connected city, and it was also the most innovative and productive.
"The challenge for Auckland is to find ways to compete with larger, more diverse cities overseas.
"For its size and location in the world, Auckland does very well, but overall New Zealand's economic diversity is quite low for an advanced country, which is reflected in our dependence on the primary sector."