History of flavor_network
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/flavor_network/__init__.py b/entries/flavor_network/__init__.py
index 246de01..9c271fe 100644
--- a/entries/flavor_network/__init__.py
+++ b/entries/flavor_network/__init__.py
@@ -41,7 +41,7 @@ The networks have the following properties:
tags = ['Chemical', 'Online', 'Unweighted', 'Metadata']
url = 'https://yongyeol.com/2011/12/15/paper-flavor-network.html'
citation = [('Y.-Y. Ahn, S. E. Ahnert, J. P. Bagrow, A.-L. Barabási, "Flavor network and the principles of food pairing." Scientific Reports 1, 196 (2011)', 'https://doi.org/10.1038/srep00196')]
-icon_hash = '593f0f4867ec90f1500d9ae7'
+date_added = '2026-10-25'
upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
# The author's site is archived by the Internet Archive; the current site has
# an invalid TLS certificate
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/flavor_network/__init__.py b/entries/flavor_network/__init__.py
index 8416a78..246de01 100644
--- a/entries/flavor_network/__init__.py
+++ b/entries/flavor_network/__init__.py
@@ -26,9 +26,18 @@ description = """Bipartite networks of food ingredients, the flavor compounds th
The networks have the following properties:
-- Ingredient nodes: `name`, the ingredient name; `category`, the ingredient category (e.g. "fruit", "plant derivative", "dairy").
-- `compounds`: `is_compound`, whether the node is a flavor compound (otherwise an ingredient). Ingredient nodes: `ingredient_id`, the ingredient id in the source. Compound nodes: `name`, the compound name; `cas`, its CAS registry number; `compound_id`, the compound id in the source.
-- `recipes`: `is_recipe`, whether the node is a recipe (otherwise an ingredient). Recipe nodes: `source`, the website the recipe was collected from ("allrecipes", "epicurious" or "menupan"); `cuisine`, the cuisine label of the recipe as given in the source (e.g. "Italian", "Korea", "Southern_SoulFood"); `region`, the regional cuisine it was mapped to (one of NorthAmerican, LatinAmerican, SouthernEuropean, WesternEuropean, EasternEuropean, NorthernEuropean, MiddleEastern, African, SouthAsian, SoutheastAsian, EastAsian; empty for the 1,193 recipes labeled generically as "Asian", which were not assigned a region); `index`, the position of the recipe in its source file (starting from 0)."""
+- (Node) `name` (ingredients): the ingredient name.
+- (Node) `category` (ingredients): the ingredient category (e.g. "fruit", "plant derivative", "dairy").
+- (Node) `is_compound` (`compounds`): whether the node is a flavor compound (otherwise an ingredient).
+- (Node) `ingredient_id` (ingredients, `compounds`): the ingredient id in the source.
+- (Node) `name` (compounds, `compounds`): the compound name.
+- (Node) `cas` (compounds, `compounds`): its CAS registry number.
+- (Node) `compound_id` (compounds, `compounds`): the compound id in the source.
+- (Node) `is_recipe` (`recipes`): whether the node is a recipe (otherwise an ingredient).
+- (Node) `source` (recipes, `recipes`): the website the recipe was collected from ("allrecipes", "epicurious" or "menupan").
+- (Node) `cuisine` (recipes, `recipes`): the cuisine label of the recipe as given in the source (e.g. "Italian", "Korea", "Southern_SoulFood").
+- (Node) `region` (recipes, `recipes`): the regional cuisine it was mapped to (one of NorthAmerican, LatinAmerican, SouthernEuropean, WesternEuropean, EasternEuropean, NorthernEuropean, MiddleEastern, African, SouthAsian, SoutheastAsian, EastAsian; empty for the 1,193 recipes labeled generically as "Asian", which were not assigned a region).
+- (Node) `index` (recipes, `recipes`): the position of the recipe in its source file (starting from 0)."""
tags = ['Chemical', 'Online', 'Unweighted', 'Metadata']
url = 'https://yongyeol.com/2011/12/15/paper-flavor-network.html'
citation = [('Y.-Y. Ahn, S. E. Ahnert, J. P. Bagrow, A.-L. Barabási, "Flavor network and the principles of food pairing." Scientific Reports 1, 196 (2011)', 'https://doi.org/10.1038/srep00196')]
[entries] Remove unneeded code from the entries 2c69f19
Unneeded "global files" statements, unused imports and variables, f-strings without placeholders, duplicate keys in foodweb_little_rock (keeping the order and the values used), and the second definition of get_lines() in twitter_higgs. Nothing changes in the networks or descriptions. Changed: none
diff --git a/entries/flavor_network/__init__.py b/entries/flavor_network/__init__.py
index bd0df83..8416a78 100644
--- a/entries/flavor_network/__init__.py
+++ b/entries/flavor_network/__init__.py
@@ -57,7 +57,6 @@ def _read_tsv(f):
@coerce_props()
@annotate()
def parse(alts=None):
- global files
name = __name__.split(".")[-1]
for fnames, alt, fmt in files:
if alts is not None and alt not in alts:
[entries] Use American spelling in the descriptions 802d564
British spellings in the titles and descriptions of 69 entries (e.g. labelled, organisation, millimetres, centres, anonymised, neighbours, analysed, modelled, colour, licence) are replaced by the American ones. Proper names keep their spelling (Otago Harbour, the Centre for Water Systems, the Centre jeunesse de Montréal, the Dutch Ministry of Defence), as do quoted upstream terms, citations, and property names.
diff --git a/entries/flavor_network/__init__.py b/entries/flavor_network/__init__.py
index ee015ab..bd0df83 100644
--- a/entries/flavor_network/__init__.py
+++ b/entries/flavor_network/__init__.py
@@ -22,13 +22,13 @@ title = "Food ingredients, flavor compounds and recipes (2011)"
description = """Bipartite networks of food ingredients, the flavor compounds they contain, and the recipes that use them, compiled by Ahn et al. to study the "food pairing" hypothesis, i.e. whether ingredients sharing flavor compounds are more likely to be combined in recipes.
- `compounds`: each food ingredient is connected to the flavor compounds it contains, as listed in Fenaroli's Handbook of Flavor Ingredients (5th edition). Five ingredients of the source list have no compounds and are not included. Note that, as stated in the upstream documentation, "farnesol" appears both as an ingredient and as a compound (as two distinct nodes).
-- `recipes`: each recipe is connected to its ingredients. The recipes were collected from the websites allrecipes.com and epicurious.com (in English) and menupan.com (in Korean), and the ingredient names were mapped onto the ingredient list of the `compounds` network; each recipe is labelled by the cuisine given by the website, and by the broader geographic region it was assigned to (the paper's analysis uses the 56,498 recipes with an assigned region).
+- `recipes`: each recipe is connected to its ingredients. The recipes were collected from the websites allrecipes.com and epicurious.com (in English) and menupan.com (in Korean), and the ingredient names were mapped onto the ingredient list of the `compounds` network; each recipe is labeled by the cuisine given by the website, and by the broader geographic region it was assigned to (the paper's analysis uses the 56,498 recipes with an assigned region).
The networks have the following properties:
- Ingredient nodes: `name`, the ingredient name; `category`, the ingredient category (e.g. "fruit", "plant derivative", "dairy").
- `compounds`: `is_compound`, whether the node is a flavor compound (otherwise an ingredient). Ingredient nodes: `ingredient_id`, the ingredient id in the source. Compound nodes: `name`, the compound name; `cas`, its CAS registry number; `compound_id`, the compound id in the source.
-- `recipes`: `is_recipe`, whether the node is a recipe (otherwise an ingredient). Recipe nodes: `source`, the website the recipe was collected from ("allrecipes", "epicurious" or "menupan"); `cuisine`, the cuisine label of the recipe as given in the source (e.g. "Italian", "Korea", "Southern_SoulFood"); `region`, the regional cuisine it was mapped to (one of NorthAmerican, LatinAmerican, SouthernEuropean, WesternEuropean, EasternEuropean, NorthernEuropean, MiddleEastern, African, SouthAsian, SoutheastAsian, EastAsian; empty for the 1,193 recipes labelled generically as "Asian", which were not assigned a region); `index`, the position of the recipe in its source file (starting from 0)."""
+- `recipes`: `is_recipe`, whether the node is a recipe (otherwise an ingredient). Recipe nodes: `source`, the website the recipe was collected from ("allrecipes", "epicurious" or "menupan"); `cuisine`, the cuisine label of the recipe as given in the source (e.g. "Italian", "Korea", "Southern_SoulFood"); `region`, the regional cuisine it was mapped to (one of NorthAmerican, LatinAmerican, SouthernEuropean, WesternEuropean, EasternEuropean, NorthernEuropean, MiddleEastern, African, SouthAsian, SoutheastAsian, EastAsian; empty for the 1,193 recipes labeled generically as "Asian", which were not assigned a region); `index`, the position of the recipe in its source file (starting from 0)."""
tags = ['Chemical', 'Online', 'Unweighted', 'Metadata']
url = 'https://yongyeol.com/2011/12/15/paper-flavor-network.html'
citation = [('Y.-Y. Ahn, S. E. Ahnert, J. P. Bagrow, A.-L. Barabási, "Flavor network and the principles of food pairing." Scientific Reports 1, 196 (2011)', 'https://doi.org/10.1038/srep00196')]
[entries] New entry: flavor_network 08ae7fe
diff --git a/entries/flavor_network/__init__.py b/entries/flavor_network/__init__.py
new file mode 100644
index 0000000..ee015ab
--- /dev/null
+++ b/entries/flavor_network/__init__.py
@@ -0,0 +1,131 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "Food ingredients, flavor compounds and recipes (2011)"
+description = """Bipartite networks of food ingredients, the flavor compounds they contain, and the recipes that use them, compiled by Ahn et al. to study the "food pairing" hypothesis, i.e. whether ingredients sharing flavor compounds are more likely to be combined in recipes.
+
+- `compounds`: each food ingredient is connected to the flavor compounds it contains, as listed in Fenaroli's Handbook of Flavor Ingredients (5th edition). Five ingredients of the source list have no compounds and are not included. Note that, as stated in the upstream documentation, "farnesol" appears both as an ingredient and as a compound (as two distinct nodes).
+- `recipes`: each recipe is connected to its ingredients. The recipes were collected from the websites allrecipes.com and epicurious.com (in English) and menupan.com (in Korean), and the ingredient names were mapped onto the ingredient list of the `compounds` network; each recipe is labelled by the cuisine given by the website, and by the broader geographic region it was assigned to (the paper's analysis uses the 56,498 recipes with an assigned region).
+
+The networks have the following properties:
+
+- Ingredient nodes: `name`, the ingredient name; `category`, the ingredient category (e.g. "fruit", "plant derivative", "dairy").
+- `compounds`: `is_compound`, whether the node is a flavor compound (otherwise an ingredient). Ingredient nodes: `ingredient_id`, the ingredient id in the source. Compound nodes: `name`, the compound name; `cas`, its CAS registry number; `compound_id`, the compound id in the source.
+- `recipes`: `is_recipe`, whether the node is a recipe (otherwise an ingredient). Recipe nodes: `source`, the website the recipe was collected from ("allrecipes", "epicurious" or "menupan"); `cuisine`, the cuisine label of the recipe as given in the source (e.g. "Italian", "Korea", "Southern_SoulFood"); `region`, the regional cuisine it was mapped to (one of NorthAmerican, LatinAmerican, SouthernEuropean, WesternEuropean, EasternEuropean, NorthernEuropean, MiddleEastern, African, SouthAsian, SoutheastAsian, EastAsian; empty for the 1,193 recipes labelled generically as "Asian", which were not assigned a region); `index`, the position of the recipe in its source file (starting from 0)."""
+tags = ['Chemical', 'Online', 'Unweighted', 'Metadata']
+url = 'https://yongyeol.com/2011/12/15/paper-flavor-network.html'
+citation = [('Y.-Y. Ahn, S. E. Ahnert, J. P. Bagrow, A.-L. Barabási, "Flavor network and the principles of food pairing." Scientific Reports 1, 196 (2011)', 'https://doi.org/10.1038/srep00196')]
+icon_hash = '593f0f4867ec90f1500d9ae7'
+upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
+# The author's site is archived by the Internet Archive; the current site has
+# an invalid TLS certificate
+upstream_prefix = 'https://web.archive.org/web/20250816095805id_/http://yongyeol.com/data'
+files = [(('ingr_comp.zip:ingr_info.tsv', 'ingr_comp.zip:comp_info.tsv',
+ 'ingr_comp.zip:ingr_comp.tsv'), 'compounds', None),
+ (('ingr_comp.zip:ingr_info.tsv',
+ 'scirep-cuisines-detail.zip:allr_recipes.txt',
+ 'scirep-cuisines-detail.zip:epic_recipes.txt',
+ 'scirep-cuisines-detail.zip:menu_recipes.txt',
+ 'scirep-cuisines-detail.zip:map.txt'), 'recipes', None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def _read_tsv(f):
+ return [l.rstrip("\r\n").split("\t") for l in f
+ if not l.startswith("#") and l.strip() != ""]
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ if isinstance(fnames, str):
+ fnames = [fnames]
+ with ExitStack() as stack:
+ fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+
+ # id, ingredient name, category
+ ingrs = {int(r[0]): (r[1], r[2]) for r in _read_tsv(fs[0])}
+
+ g = Graph(directed=False)
+ g.vp.name = g.new_vp("string")
+ g.vp.category = g.new_vp("string")
+
+ if alt == "compounds":
+ # id, compound name, CAS number
+ comps = {int(r[0]): (r[1], r[2]) for r in _read_tsv(fs[1])}
+ # ingredient id, compound id
+ edges = [(int(r[0]), int(r[1])) for r in _read_tsv(fs[2])]
+ iids = sorted(set(i for i, c in edges))
+ cids = sorted(set(c for i, c in edges))
+ iidx = {i: n for n, i in enumerate(iids)}
+ cidx = {c: len(iids) + n for n, c in enumerate(cids)}
+ g.add_vertex(len(iids) + len(cids))
+ g.vp.is_compound = g.new_vp("bool")
+ g.vp.ingredient_id = g.new_vp("int")
+ g.vp.compound_id = g.new_vp("int")
+ g.vp.cas = g.new_vp("string")
+ for i, v in iidx.items():
+ g.vp.name[v], g.vp.category[v] = ingrs[i]
+ g.vp.ingredient_id[v] = i
+ for c, v in cidx.items():
+ g.vp.is_compound[v] = True
+ g.vp.name[v], g.vp.cas[v] = comps[c]
+ g.vp.compound_id[v] = c
+ g.add_edge_list([(iidx[i], cidx[c]) for i, c in edges])
+ else:
+ cats = dict(ingrs.values())
+ # cuisine label -> region (empty if not assigned)
+ regions = {r[0]: r[1] if len(r) > 1 else ""
+ for r in _read_tsv(fs[4])}
+ recipes = []
+ for source, f in zip(["allrecipes", "epicurious", "menupan"],
+ fs[1:4]):
+ for i, r in enumerate(_read_tsv(f)):
+ recipes.append((source, i, r[0], r[1:]))
+ inames = sorted(set(x for rec in recipes for x in rec[3]))
+ iidx = {x: n for n, x in enumerate(inames)}
+ NI = len(inames)
+ g.add_vertex(NI + len(recipes))
+ g.vp.is_recipe = g.new_vp("bool")
+ g.vp.source = g.new_vp("string")
+ g.vp.cuisine = g.new_vp("string")
+ g.vp.region = g.new_vp("string")
+ g.vp.index = g.new_vp("int")
+ for x, v in iidx.items():
+ g.vp.name[v] = x
+ g.vp.category[v] = cats.get(x, "")
+ edges = []
+ for n, (source, i, cuisine, ings) in enumerate(recipes):
+ v = NI + n
+ g.vp.is_recipe[v] = True
+ g.vp.source[v] = source
+ g.vp.cuisine[v] = cuisine
+ g.vp.region[v] = regions[cuisine]
+ g.vp.index[v] = i
+ edges.extend((v, iidx[x]) for x in ings)
+ g.add_edge_list(edges)
+ yield alt, g