Function Repository Resource:

FoodWeb

Source Notebook

Visualize food chains of a given animal species

Contributed by: Keiko Hirayama

ResourceFunction["FoodWeb"][species]

visualizes the predator-prey network for a specified species entity.

ResourceFunction["FoodWeb"][species,property]

visualizes the food network for species based on property.

ResourceFunction["FoodWeb"][species,property,n]

gives the graph obtained by starting with species and querying the property successively n times.

Details and Options

ResourceFunction["FoodWeb"] illustrates the predator-prey relationships of animals.
ResourceFunction["FoodWeb"] returns a Graph object.
Selected "TaxonomicSpecies" entities can be used.
Supported values of property include the following:
"Both"show the species along with its predators and prey (default)
"Predator"show the species and its predators
"Prey"show the species and its prey
In FoodWeb[species, property, n], n should be in the range 1n5. For example, requesting "Prey" and specifying n=2 will give a graph with links from the species to each of its prey, and also links from each of the latter to all of their respective prey.
FoodWeb[species] is equivalent to FoodWeb[species, "Both", 1].
FoodWeb[species, property] is equivalent to FoodWeb[species, property, 1].
ResourceFunction["FoodWeb"] takes the same options as Graph.

Examples

Basic Examples (2) 

Generate a graph illustrating predator-prey relations for cheetahs:

In[1]:=
ResourceFunction["FoodWeb"][
 Entity["TaxonomicSpecies", "AcinonyxJubatus::22ksf"]]
Out[1]=

Generate a graph based on a prey relation:

In[2]:=
ResourceFunction["FoodWeb"][
 Entity["TaxonomicSpecies", "OndatraZibethicus::5f49t"], "Prey", 2]
Out[2]=

Options (2) 

GraphHighlight (1) 

Highlight an animal of interest:

In[3]:=
ResourceFunction["FoodWeb"][
 Entity["TaxonomicSpecies", "KatsuwonusPelamis::tbx2c"], 2, GraphHighlight -> Entity["TaxonomicSpecies", "KatsuwonusPelamis::tbx2c"]]
Out[3]=

GraphLayout (1) 

Specify the layout of a graph:

In[4]:=
ResourceFunction["FoodWeb"][
 Entity["TaxonomicSpecies", "CanisLatrans::bcz7p"], 2, GraphLayout -> "RadialEmbedding"]
Out[4]=

Possible Issues (1) 

Predator-prey information is available for selected animal species only. Trying to visualize a non-animal species entity returns Missing:

In[5]:=
ResourceFunction["FoodWeb"][
 Entity["TaxonomicSpecies", "Saccharomyces::r58fh"], "Predator"]
Out[5]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 18 December 2023

Related Resources

License Information