<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="th">
	<id>http://158.108.32.49/wiki/index.php?action=history&amp;feed=atom&amp;title=418531_%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%95%E0%B9%89%E0%B8%99_2552%2F%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%A7%E0%B8%B1%E0%B8%95_II%2F%E0%B9%80%E0%B8%89%E0%B8%A5%E0%B8%A2%E0%B8%82%E0%B9%89%E0%B8%AD_3</id>
	<title>418531 ภาคต้น 2552/โจทย์ปัญหาการโปรแกรมพลวัต II/เฉลยข้อ 3 - ประวัติรุ่นแก้ไข</title>
	<link rel="self" type="application/atom+xml" href="http://158.108.32.49/wiki/index.php?action=history&amp;feed=atom&amp;title=418531_%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%95%E0%B9%89%E0%B8%99_2552%2F%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%A7%E0%B8%B1%E0%B8%95_II%2F%E0%B9%80%E0%B8%89%E0%B8%A5%E0%B8%A2%E0%B8%82%E0%B9%89%E0%B8%AD_3"/>
	<link rel="alternate" type="text/html" href="http://158.108.32.49/wiki/index.php?title=418531_%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%95%E0%B9%89%E0%B8%99_2552/%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%A7%E0%B8%B1%E0%B8%95_II/%E0%B9%80%E0%B8%89%E0%B8%A5%E0%B8%A2%E0%B8%82%E0%B9%89%E0%B8%AD_3&amp;action=history"/>
	<updated>2026-05-05T02:46:24Z</updated>
	<subtitle>ประวัติรุ่นแก้ไขของหน้านี้ในวิกิ</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>http://158.108.32.49/wiki/index.php?title=418531_%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%95%E0%B9%89%E0%B8%99_2552/%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%A7%E0%B8%B1%E0%B8%95_II/%E0%B9%80%E0%B8%89%E0%B8%A5%E0%B8%A2%E0%B8%82%E0%B9%89%E0%B8%AD_3&amp;diff=7695&amp;oldid=prev</id>
		<title>Cardcaptor: หน้าที่ถูกสร้างด้วย &#039;อัลกอริทึมในการหา cycle ที่สั้นที่สุดมีดังต่อไปนี้ #…&#039;</title>
		<link rel="alternate" type="text/html" href="http://158.108.32.49/wiki/index.php?title=418531_%E0%B8%A0%E0%B8%B2%E0%B8%84%E0%B8%95%E0%B9%89%E0%B8%99_2552/%E0%B9%82%E0%B8%88%E0%B8%97%E0%B8%A2%E0%B9%8C%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%A7%E0%B8%B1%E0%B8%95_II/%E0%B9%80%E0%B8%89%E0%B8%A5%E0%B8%A2%E0%B8%82%E0%B9%89%E0%B8%AD_3&amp;diff=7695&amp;oldid=prev"/>
		<updated>2009-10-04T11:51:00Z</updated>

		<summary type="html">&lt;p&gt;หน้าที่ถูกสร้างด้วย &amp;#039;อัลกอริทึมในการหา cycle ที่สั้นที่สุดมีดังต่อไปนี้ #…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;หน้าใหม่&lt;/b&gt;&lt;/p&gt;&lt;div&gt;อัลกอริทึมในการหา cycle ที่สั้นที่สุดมีดังต่อไปนี้&lt;br /&gt;
# รัน Floyd&amp;#039;s algorithm บนกราฟ &amp;lt;math&amp;gt;G \,&amp;lt;/math&amp;gt; และสมมติให้ output ของมันอยู่ในอะเรย์ &amp;lt;math&amp;gt;M[\cdot, \cdot] \,&amp;lt;/math&amp;gt;&lt;br /&gt;
# สำหรับ edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; แต่ละ edge ใน &amp;lt;math&amp;gt;G \,&amp;lt;/math&amp;gt; ให้คำนวณค่า &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)} \,&amp;lt;/math&amp;gt; โดยที่ &amp;lt;math&amp;gt;\ell_{(u,v)} \,&amp;lt;/math&amp;gt; คือความยาวของ edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; แล้วจำค่า &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)} \,&amp;lt;/math&amp;gt; ที่ต่ำสุดเอาไว้&lt;br /&gt;
# ถ้าค่าที่ต่ำที่สุดในข้อ 2 เป็น &amp;lt;math&amp;gt;\infty \,&amp;lt;/math&amp;gt; ก็ให้ตอบว่าไม่มี cycle มิเช่นนั้นให้คืนมันเป็นคำตอบ&lt;br /&gt;
&lt;br /&gt;
เราสามารถแสดงว่าคำตอบของอัลกอริทึมข้างบนคืนมาเป็นความยาวของ cycle ที่สั้นสุด ได้ดังต่อไปนี้ &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;กรณีที่ 1:&amp;#039;&amp;#039;&amp;#039; ถ้ากราฟไม่มี cycle เราจะได้ว่าสำหรับทุกๆ edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; จะไม่มี path จาก &amp;lt;math&amp;gt;v \,&amp;lt;/math&amp;gt; ไปยัง &amp;lt;math&amp;gt;u \,&amp;lt;/math&amp;gt; ดังนั้น &amp;lt;math&amp;gt;M[v,u] = \infty \,&amp;lt;/math&amp;gt; เสมอ ด้วยเหตุนี้ค่า &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)} \,&amp;lt;/math&amp;gt; ที่ต่ำที่สุดจึงมีค่าเท่ากับ &amp;lt;math&amp;gt;\infty \,&amp;lt;/math&amp;gt; และอัลกอริทึมข้างบนจะตอบว่ากราฟไม่มี cycle ได้อย่างถูกต้อง&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;กรณีที่ 2&amp;#039;&amp;#039;&amp;#039; ถ้ากราฟมี cycle เราจะได้ว่ามี edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; อย่างน้อยหนึ่ง edge ที่ทำให้ &amp;lt;math&amp;gt;M[u,v]  + \ell_{(u,v)}\,&amp;lt;/math&amp;gt; มีค่าน้อยกว่า &amp;lt;math&amp;gt;\infty \,&amp;lt;/math&amp;gt; เราจะต้องแสดงว่าค่า &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)} \,&amp;lt;/math&amp;gt; ที่น้อยที่สุดคือความยาวของ cycle ที่สั้นที่สุด&lt;br /&gt;
&lt;br /&gt;
อันดับแรก ให้พิจารณา edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; ใดๆ เราได้ว่า &amp;lt;math&amp;gt;M[v,u] \,&amp;lt;/math&amp;gt; คือความยาวของ shortest path จาก &amp;lt;math&amp;gt;v \,&amp;lt;/math&amp;gt; ไปยัง &amp;lt;math&amp;gt;u \,&amp;lt;/math&amp;gt; &lt;br /&gt;
ด้วยเหตุนี้ &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)}\,&amp;lt;/math&amp;gt; จึงเป็นความยาวของ cycle ที่สั้นที่สุดที่มี edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; &lt;br /&gt;
(เราสามารถแสดงว่าข้อความสุดท้ายนี้เป็นจริงได้โดยการสมมติให้เกิดข้อขัดแย้งว่า &amp;lt;math&amp;gt;M[v,u] + \ell_{(u,v)} \,&amp;lt;/math&amp;gt; &lt;br /&gt;
ไม่ใช่ความยาวของ cycle ที่สั้นที่สุดที่มี edge &amp;lt;math&amp;gt;(u,v) \,&amp;lt;/math&amp;gt; แต่เราจะได้ว่า cycle นั้นจะต้องมี path จาก &amp;lt;math&amp;gt;v \,&amp;lt;/math&amp;gt; ไปยัง &amp;lt;math&amp;gt;u \,&amp;lt;/math&amp;gt; &lt;br /&gt;
และไม่มี path จาก v ไป u ที่มีความยาวน้อยกว่า &amp;lt;math&amp;gt;M[v,u] \,&amp;lt;/math&amp;gt; แล้ว ทำให้เกิดข้อขัดแย้งขึ้น)&lt;br /&gt;
&lt;br /&gt;
อันดับที่สอง เนื่องจาก cycle ที่สั้นที่สุดจะต้องผ่าน edge อย่างน้อย 1 edge เราจึงได้ว่าการนำความยาว cycle ที่สั้นที่สุดที่ผ่าน edge แต่ละ edge มาเปรียบเทียบกัน&lt;br /&gt;
เพื่อหาความยาวที่น้อยที่สุดจะทำให้เราได้ความยาวของ cycle ที่สั้นที่สุดเสมอ&lt;br /&gt;
&lt;br /&gt;
ด้วยเหตุนี้เราจึงสามารถสรุปได้ว่า ถ้ากราฟมี cycle แล้ว อัลกอริทึมข้างบนจะตอบความยาวของ cycle ที่สั้นที่สุดมาเสมอ&lt;br /&gt;
&lt;br /&gt;
เราเห็นได้ชัดว่าการทำงานในขั้นตอนที่ 1 ของอัลกอริทึมข้างบนใช้เวลา &amp;lt;math&amp;gt;O(|V|^3) \,&amp;lt;/math&amp;gt; และการทำงานขั้นที่สองใช้เวลา &amp;lt;math&amp;gt;O(|E|) = O(|V^2|) \,&amp;lt;/math&amp;gt; ดังนั้นอัลกอริทึมข้างบนจึงทำงานได้ในเวลา &amp;lt;math&amp;gt;O(|V|^3) \,&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cardcaptor</name></author>
		
	</entry>
</feed>