twa_graph: swap the two passes of merge_edges()

This improves the determinism in a few cases.

* spot/twa/twagraph.cc (merge_edges): Encapsulate the two
passes into lambdas so that they are very easy to swap.
* spot/twa/twagraph.hh (merge_edges): Adjust documentation.
* tests/python/mergedge.py: Add test case.
* tests/core/alternating.test, tests/python/alternation.ipynb:
Determinism was improved.
* tests/core/parity2.test, tests/core/readsave.test,
tests/core/sbacc.test, tests/python/_product_susp.ipynb,
tests/python/atva16-fig2a.ipynb, tests/python/decompose.ipynb,
tests/python/highlighting.ipynb, tests/python/satmin.ipynb,
tests/python/simstate.py: Adjust expected order of edges.
* NEWS: Mention the change.
This commit is contained in:
Alexandre Duret-Lutz 2021-01-19 20:58:04 +01:00
parent e8e31c2723
commit 2072151499
15 changed files with 1963 additions and 1896 deletions

View file

@ -200,7 +200,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000ab150> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc092f00> >"
]
},
"execution_count": 2,
@ -330,7 +330,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb015474e0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc211360> >"
]
},
"execution_count": 3,
@ -489,7 +489,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000ab360> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc23f3c0> >"
]
},
"execution_count": 4,
@ -587,7 +587,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000ab840> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea4e0> >"
]
},
"execution_count": 5,
@ -655,21 +655,21 @@
"<title>0&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M52.76,-51.78C52.21,-61.31 53.29,-70 56,-70 57.99,-70 59.1,-65.32 59.33,-59.05\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"59.24,-51.78 62.48,-58.74 59.28,-55.28 59.33,-58.78 59.33,-58.78 59.33,-58.78 59.28,-55.28 56.18,-58.82 59.24,-51.78 59.24,-51.78\"/>\n",
"<text text-anchor=\"start\" x=\"36.5\" y=\"-88.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !c</text>\n",
"<text text-anchor=\"start\" x=\"48\" y=\"-73.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"38.5\" y=\"-73.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; !c</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;0 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>0&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M50.99,-51.58C47.55,-72.72 49.21,-100 56,-100 62.04,-100 64.03,-78.36 61.96,-58.69\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"61.01,-51.58 65.06,-58.1 61.47,-55.05 61.93,-58.52 61.93,-58.52 61.93,-58.52 61.47,-55.05 58.81,-58.93 61.01,-51.58 61.01,-51.58\"/>\n",
"<text text-anchor=\"start\" x=\"38.5\" y=\"-103.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; !c</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M50.68,-51.42C47.65,-68.79 49.43,-88 56,-88 61.7,-88 63.79,-73.55 62.27,-58.39\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"61.32,-51.42 65.39,-57.93 61.79,-54.89 62.26,-58.36 62.26,-58.36 62.26,-58.36 61.79,-54.89 59.14,-58.78 61.32,-51.42 61.32,-51.42\"/>\n",
"<text text-anchor=\"start\" x=\"36.5\" y=\"-106.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !c</text>\n",
"<text text-anchor=\"start\" x=\"48\" y=\"-91.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abb40> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea840> >"
]
},
"execution_count": 6,
@ -796,7 +796,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abd50> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0eaab0> >"
]
},
"metadata": {},
@ -941,7 +941,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abf00> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc20bc60> >"
]
},
"metadata": {},
@ -1109,7 +1109,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00d0fd80> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc092cc0> >"
]
},
"metadata": {},
@ -1512,7 +1512,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000ab390> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea570> >"
]
},
"execution_count": 8,
@ -1942,7 +1942,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00064e40> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0eaa50> >"
]
},
"metadata": {},
@ -1957,8 +1957,8 @@
"<!-- Generated by graphviz version 2.43.0 (0)\n",
" -->\n",
"<!-- Title: strictly weak Pages: 1 -->\n",
"<svg width=\"734pt\" height=\"294pt\"\n",
" viewBox=\"0.00 0.00 734.00 293.99\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<svg width=\"729pt\" height=\"292pt\"\n",
" viewBox=\"0.00 0.00 729.00 291.98\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(0.9174311926605504 0.9174311926605504) rotate(0) translate(4 315.22)\">\n",
"<title>strictly weak</title>\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-315.22 793,-315.22 793,4 -4,4\"/>\n",
@ -2174,7 +2174,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00064e10> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc092cc0> >"
]
},
"metadata": {},
@ -2384,7 +2384,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abed0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc21dea0> >"
]
},
"metadata": {},
@ -2772,7 +2772,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00cd01e0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea7b0> >"
]
},
"execution_count": 10,
@ -2793,7 +2793,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -2933,7 +2933,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000798a0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ab3f0> >"
]
},
"metadata": {},
@ -3072,7 +3072,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079660> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc211570> >"
]
},
"metadata": {},
@ -3224,7 +3224,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079750> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc23fa80> >"
]
},
"metadata": {},
@ -3252,7 +3252,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@ -3577,10 +3577,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00d0f0f0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc21d750> >"
]
},
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@ -3641,7 +3641,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -3960,7 +3960,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079420> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea480> >"
]
},
"metadata": {},
@ -4137,7 +4137,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb01538de0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc23fae0> >"
]
},
"metadata": {},
@ -4295,7 +4295,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00d0f360> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc092c00> >"
]
},
"metadata": {},
@ -4320,7 +4320,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@ -4644,10 +4644,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abd50> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea3c0> >"
]
},
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@ -4673,7 +4673,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -4767,10 +4767,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079330> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc23fbd0> >"
]
},
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@ -4781,7 +4781,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@ -4791,7 +4791,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@ -4865,7 +4865,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079660> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0eac90> >"
]
},
"metadata": {},
@ -4941,7 +4941,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abea0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc21d7e0> >"
]
},
"metadata": {},
@ -4962,7 +4962,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@ -5035,10 +5035,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000791b0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0eaab0> >"
]
},
"execution_count": 19,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@ -5065,7 +5065,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@ -5185,10 +5185,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079300> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ab6f0> >"
]
},
"execution_count": 20,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -5226,7 +5226,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"metadata": {},
"outputs": [
{
@ -5345,7 +5345,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079d50> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0abb70> >"
]
},
"metadata": {},
@ -5447,7 +5447,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abcf0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc092c00> >"
]
},
"metadata": {},
@ -5582,7 +5582,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000abe70> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0abae0> >"
]
},
"metadata": {},
@ -5611,7 +5611,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"outputs": [
{
@ -5786,7 +5786,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000ab930> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea1e0> >"
]
},
"metadata": {},
@ -5927,10 +5927,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb00079db0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0ea630> >"
]
},
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@ -5953,7 +5953,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@ -6030,10 +6030,10 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fbb000792d0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f09cc0eae70> >"
]
},
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@ -6041,13 +6041,6 @@
"source": [
"spot.decompose_scc(si, 'a2')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -6066,7 +6059,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.1+"
}
},
"nbformat": 4,