Food Webs

Ecology and Ecosystems Fundamentals

Course 1 · Chapter 3 · Food Webs

Chapter 2 followed energy up a single, tidy chain: grass, deer, eagle. Real life is messier. The eagle also eats hares and the occasional fox, the fox eats hares and carrion, and the hare eats heather as well as grass. Draw every one of those arrows and the chain becomes a net. This chapter is about that net, the food web: how to describe it, how to measure how tangled it is, and why a few species hold the whole structure up far out of proportion to their numbers. We will build small webs in Python, remove species to see what happens, and watch a famous domino effect called a trophic cascade. The maths stays light: counting and simple percentages.

What to trust in this chapter
The Python snippets here and in the three exercise solutions were run, and the output in the comments is what Python printed. The webs and the kelp model are invented to show a method: the species are real but the diets are simplified and every rate is illustrative. The ecological history (the starfish experiments, the sea otters, wolves and beavers) is written from general knowledge, not fetched from a source for this chapter, and some of it, especially the wolves, is still debated by ecologists. Check it against a current textbook before relying on it.

From Chains to Webs

A food web is the set of all the feeding links in a community. Each species is a node and each “eats” relationship is a link (an arrow from the eaten to the eater, or, as in our code, a list of what each species eats). Compared with a chain, a web has two important features. First, most consumers have several food sources, so they can switch when one becomes scarce. Second, most species are eaten by several predators, so no single predator controls them completely.

Food chain (Chapter 2)Food web (this chapter)
ShapeOne line of arrowsA network with many crossing arrows
DietOne food per speciesSeveral foods per species (generalists) or few (specialists)
If a species vanishesEverything above it starvesOthers can often switch food, but not always
Best forFollowing energy loss level by levelUnderstanding stability and indirect effects

Here is a small invented Highland web written as a Python dictionary, with a few lines to count its species and links. This is a handy way to hold any web: each key eats the species in its list, and the producers have an empty list.

# A tiny food web as a dictionary: each animal maps to the things it eats (invented Highland web). web = { "heather": [], "grass": [], "red deer": ["heather", "grass"], "mountain hare": ["heather", "grass"], "stoat": ["mountain hare"], "fox": ["mountain hare", "red deer"], "golden eagle": ["mountain hare", "stoat", "fox"], } species = len(web) links = sum(len(prey) for prey in web.values()) print(f"{species} species, {links} feeding links") for name, prey in web.items(): eaten_by = [p for p, diet in web.items() if name in diet] print(f"{name:14s} eats {len(prey)}, eaten by {len(eaten_by)}") connectance = links / (species * (species - 1)) print(f"connectance (links / possible links): {connectance:.3f}") # Output: # 7 species, 10 feeding links # heather eats 0, eaten by 2 # grass eats 0, eaten by 2 # red deer eats 2, eaten by 1 # mountain hare eats 2, eaten by 3 # stoat eats 1, eaten by 1 # fox eats 2, eaten by 1 # golden eagle eats 3, eaten by 0 # connectance (links / possible links): 0.238

Connectance is the fraction of all possible links that actually exist: here 10 out of 7 × 6 = 42, or 0.238. Real webs are far from fully connected; most species eat only a small fraction of what is available, which is why connectance values are usually well below 0.5. Notice also that the mountain hare is eaten by three different predators and eats two foods: it is the busy middle of this web, and a hare crash would be felt in several places at once.

Trophic Level in a Web: Fractions Appear

In a chain, trophic levels are whole numbers. In a web an omnivore feeds at several levels, so ecologists give it a fractional level: 1 plus the average level of its diet. A fox that eats half mice (level 2) and half owls (level 3) sits at 1 + 2.5 = 3.5. The recursion is natural to code.

# Fractional trophic level = 1 + average level of the diet. web = { "grass": [], "mouse": ["grass"], "vole": ["grass"], "owl": ["mouse", "vole"], "fox": ["mouse", "owl"], } levels = {} def level(name): if name in levels: return levels[name] diet = web[name] levels[name] = 1.0 if not diet else 1 + sum(level(p) for p in diet) / len(diet) return levels[name] for name in web: print(f"{name:6s} trophic level {level(name):.2f}") # Output: # grass trophic level 1.00 # mouse trophic level 2.00 # vole trophic level 2.00 # owl trophic level 3.00 # fox trophic level 3.50

The fox lands at 3.50, between owl and mouse, just as the sum said. People are omnivores too, and the average human diet sits somewhere between 2 and 3 depending on how much meat it contains, which links back to the energy argument in Ecology and Ecosystems Fundamentals 2.

Not All Species Are Equal: Keystones

If you counted links alone you might guess that the best-connected species matter most. Often the opposite is true: a few species have an effect on their community far larger than their numbers or their mass would suggest. These are keystone species, named by analogy with the central stone of an arch: remove it and the arch falls, though it is only one stone among many. The idea comes from the American ecologist Robert Paine, who in the 1960s kept removing a starfish (the purple sea star) from rocky shore plots on the Pacific coast. Without the starfish, mussels spread over the rock, crowded out most other species and the plot lost much of its variety.

ExampleWhereWhat it doesIf it is lost
Purple sea starPacific rocky shoresEats mussels, keeping them from monopolising the rockMussels take over; diversity falls
Sea otterNorth Pacific kelp forestsEats sea urchinsUrchins overgraze kelp, leaving bare “urchin barrens”
BeaverRivers of Europe and North AmericaAn ecosystem engineer: dams create ponds and wetlandsFewer pools, less wetland habitat for fish, amphibians and birds
WolfYellowstone, USAEats and frightens deer and elkGrazers browse young trees heavily (the strength of this effect is debated)

Beavers deserve a Scottish note. They were hunted to extinction in Britain several centuries ago. A trial reintroduction began at Knapdale in Argyll in 2009, and a separate wild population on the River Tay in Tayside grew from escapes, and beavers in Scotland have since been given official protected status. Watching what their dams do to local wildlife is a live experiment in keystone ecology. Keystone species are not always predators: the beaver is a builder, not a hunter.

Link counts cannot find keystones
A species that is eaten by many and eats many may still be easy to replace. A keystone is defined by the effect of removing it, not by how many arrows touch it. That is why ecologists do removal experiments, and why the next sections test removals in code.

Removing a Species: the Bottom-Up Test

A simple thought experiment is to delete one species from the web and see who is left with nothing to eat. This is a secondary extinction test. It catches loss of food, working from the bottom upward, and it is a rough tool, but it shows an important idea: webs with many alternative foods are more robust than webs where an animal depends on a single species.

# Remove one species and see who loses ALL their food (a secondary extinction). web = { "kelp": [], "urchin": ["kelp"], "limpet": ["kelp"], "sea otter": ["urchin"], "fish": ["kelp", "limpet"], "seal": ["fish"], } def lose(web, removed): gone = {removed} changed = True while changed: changed = False for sp, diet in web.items(): if sp in gone or not diet: continue if all(p in gone for p in diet): gone.add(sp) changed = True return gone - {removed} for sp in web: print(f"remove {sp:10s} -> also lost: {sorted(lose(web, sp)) or 'nobody'}") # Output: # remove kelp -> also lost: ['fish', 'limpet', 'sea otter', 'seal', 'urchin'] # remove urchin -> also lost: ['sea otter'] # remove limpet -> also lost: nobody # remove sea otter -> also lost: nobody # remove fish -> also lost: ['seal'] # remove seal -> also lost: nobody

Removing the kelp, the one producer, collapses everything, which is no surprise. Removing the urchin starves the otter, which has no other food in this simplified web. Removing the limpet harms nobody, because the fish also eat kelp. The surprise is in the sea otter row: removing it loses nobody by this test, yet in real kelp forests the loss of otters is disastrous. The test is blind to effects that run from the top down, and those are the subject of the next section.

Trophic Cascades: Effects That Run Downhill

A trophic cascade is an indirect effect that passes down through the levels. Take away a top predator, its prey increases, and that prey then eats more of whatever lies below it. In North Pacific kelp forests the sea otter eats urchins; when otters were hunted for their fur, urchin numbers rose, grazed the kelp to the rock and left an “urchin barren” with far fewer fish and other animals. When otters returned, kelp came back. The same logic works in lakes (fish-eating fish, small fish, water fleas, algae) and is a main reason fisheries managers worry about removing top predators from the sea.

The sketch below is a yearly model with invented rates: otters reduce the urchin growth rate, and urchins graze the kelp, which also regrows a little each year. It runs eight years for four different otter populations.

# Trophic cascade: otters eat urchins, urchins eat kelp. Yearly steps, invented rates. def run(otters, years=8): urchins, kelp = 100.0, 100.0 for y in range(years): urchins *= 1.5 - 0.02 * otters # urchin growth is cut by otter predation urchins = min(urchins, 1000.0) kelp -= 0.05 * urchins # urchins graze kelp kelp += 10 # kelp regrows a little kelp = max(0.0, min(kelp, 100.0)) return urchins, kelp for otters in [0, 10, 25, 40]: u, k = run(otters) print(f"otters {otters:3d}: urchins {u:7.1f}, kelp {k:5.1f}") # Output: # otters 0: urchins 1000.0, kelp 0.0 # otters 10: urchins 815.7, kelp 19.9 # otters 25: urchins 100.0, kelp 100.0 # otters 40: urchins 5.8, kelp 100.0

With no otters the urchins hit their cap of 1,000 and the kelp is gone. With 25 otters the urchin population simply holds steady at 100 and the kelp stays full. Notice that the otters never touch the kelp: their effect on it is entirely indirect, passed through the urchins. That is the signature of a cascade, and it is why the bottom-up test above could not see it. Real cascades are rarely this clean, since other predators, disease, storms and food supply all push on the same numbers, but the structure of the effect is the same.

Why Webs Are Fragile and Robust at Once

Ecologists have long argued about whether complexity makes ecosystems stable. The practical picture is mixed. A web with many alternative links tolerates the loss of a random species well, because most species have a back-up food. But the same web can be badly damaged by the loss of one particular species, a keystone or a base producer, and by the arrival of a new one: an invasive predator in a web whose animals have never met it can cascade through everything (Ecology and Ecosystems Fundamentals 11 returns to this). Rare species are not always the least important ones.

Common mistakes
Do not call a species a keystone just because it is common or well connected: the test is the size of the effect of removing it. Do not assume cascades always happen: they are strong in some ecosystems (lakes, kelp forests) and weak in others, and the Yellowstone wolf story is still argued over. Do not forget that the food web in a diagram is a simplification: real diets change with season, age and what is available. And a chain is not a web: do not draw one line of arrows and call it the ecosystem.

Challenges

Exercise 1

An invented loch web: algae and water plants (producers); snails eat both; water fleas eat algae; minnows eat water fleas and snails; trout eat minnows, snails and water fleas; otters eat trout and minnows; herons eat minnows and trout. Store it as a dictionary, print the number of species, the number of links and the connectance, rank every species by total links (eats plus eaten by), and list the top predators (species eaten by nobody).

📄 View solution
Exercise 2

Using the same loch web, run the removal test for every species with the lose function from this chapter. Which removal does the most damage, and why are so few removals harmful in this test? Explain in a sentence why this test would not find a keystone predator.

📄 View solution
Exercise 3

Reuse the kelp cascade model and run it for 0 to 40 otters in steps of 5. Then find the smallest whole number of otters that keeps the kelp at 50 or more after eight years, and say what the sharp change tells you about thresholds in cascades.

📄 View solution

Quick Reference

  • Food web: the network of all feeding links; most species have several foods and several predators
  • Connectance: links divided by possible links (species × (species − 1)); real webs are well below 1
  • Fractional trophic level: 1 plus the average level of the diet
  • Keystone species: an outsized effect on the community, judged by what happens when it is removed
  • Ecosystem engineer: a species such as the beaver that changes the habitat itself
  • Trophic cascade: an indirect effect running down through the levels; strong in some ecosystems, weak in others
Coming next
Ecology and Ecosystems Fundamentals 4 follows the matter instead of the energy: how carbon, nitrogen, phosphorus and water cycle through ecosystems.