...
 
Commits (2)
......@@ -13,7 +13,7 @@
"source": [
"This notebook provides additional documentation to the functions in [dom_enum.py](dom_enum.py).\n",
"It is part of the [domenum](https://gitlab.tubit.tu-berlin.de/jraymond/domenum) repository containing an implementation of the algorithm described in the following article:\n",
" * *Enumerating minimal dominating sets in triangle-free graphs*, Marthe Bonamy, Oscar Defrain, Marc Heinrich, and Jean-Florent Raymond. 2018. [arxiv:1810.00789](https://arxiv.org/abs/1810.00789)."
" * *Enumerating minimal dominating sets in $K_t$-free graphs and variants*, Marthe Bonamy, Oscar Defrain, Marc Heinrich, Michał Pilipczuk, and Jean-Florent Raymond. 2019. [arxiv:1810.00789](https://arxiv.org/abs/1810.00789)."
]
},
{
......@@ -41,14 +41,14 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<generator object dom_enum at 0x7f467d2b7dc0>\n",
"<generator object minimal_dominating_sets at 0x7f6ecfeca870>\n",
"set([0, 2, 4])\n",
"set([1, 4])\n",
"set([0, 3])\n",
......@@ -58,7 +58,7 @@
],
"source": [
"G = graphs.PathGraph(5)\n",
"de = dom_enum(G)\n",
"de = minimal_dominating_sets(G)\n",
"print(de)\n",
"for d in de:\n",
" print(d)"
......@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 3,
"metadata": {},
"outputs": [
{
......@@ -105,7 +105,7 @@
],
"source": [
"G = graphs.PetersenGraph()\n",
"for d in dom_enum(G):\n",
"for d in minimal_dominating_sets(G):\n",
" print(d)"
]
},
......@@ -129,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -146,7 +146,7 @@
],
"source": [
"G = graphs.PathGraph(5)\n",
"de = dom_enum(G, {1,3}) # we only want to dominate 1 and 3\n",
"de = minimal_dominating_sets(G, {1,3}) # we only want to dominate 1 and 3\n",
"for d in de:\n",
" print(d)"
]
......@@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
......@@ -208,7 +208,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 8,
"metadata": {},
"outputs": [
{
......@@ -230,7 +230,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 9,
"metadata": {},
"outputs": [
{
......@@ -239,7 +239,7 @@
"(True, None)"
]
},
"execution_count": 24,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
......@@ -255,7 +255,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 10,
"metadata": {},
"outputs": [
{
......@@ -297,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
......@@ -310,7 +310,7 @@
" print(\"* testing dom_enum on graph #\" + str(i))\n",
" G = graphs.RandomGNP(n, p)\n",
"\n",
" ll = list(dom_enum(G, G.vertices()))\n",
" ll = list(minimal_dominating_sets(G, G.vertices()))\n",
" r = dom_enum_decision(G, ll) # check if the output of dom_enum is correct\n",
"\n",
" if not r[0]:\n",
......@@ -324,7 +324,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 12,
"metadata": {},
"outputs": [
{
......@@ -353,7 +353,7 @@
"True"
]
},
"execution_count": 31,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
......@@ -371,7 +371,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
......@@ -386,7 +386,7 @@
" for G in graphs(n):\n",
" print(\"* testing dom_enum on graph #\" + str(i) + \"...\")\n",
"\n",
" ll = list(dom_enum(G, G.vertices()))\n",
" ll = list(minimal_dominating_sets(G, G.vertices()))\n",
" r = dom_enum_decision(G, ll)\n",
" \n",
" if not r[0]:\n",
......@@ -406,7 +406,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 16,
"metadata": {
"scrolled": true
},
......@@ -449,7 +449,7 @@
"True"
]
},
"execution_count": 36,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
......@@ -474,7 +474,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
......@@ -504,7 +504,7 @@
" base_name = dt.strftime(\"%Y-%m-%d_%H-%M-%S_img\") # the base for images names\n",
" \n",
" i = 0\n",
" for min_ds in dom_enum(G):\n",
" for min_ds in minimal_dominating_sets(G):\n",
" G.plot(vertex_labels=False, vertex_colors={'red': list(min_ds)}, vertex_color='black').save(directory + '/' + base_name + str(i) + '.png')\n",
" i += 1\n",
" os.system('convert -resize 50% -delay 20 -loop 0 ' + directory + '/' + base_name + '*.png ' + directory + '/output.gif') "
......@@ -512,7 +512,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
......@@ -523,11 +523,25 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"After running the command above and this cell, you should see the minimal dominating sets of the Petersen graph:\n",
"After running the command above **and this cell**, you should see the minimal dominating sets of the Petersen graph:\n",
"![animated Petersen](img/output.gif)\n",
"\n",
"(this may fail on binder)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......