<?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=Adt_lab%2Fadjlist_and_bfs</id>
	<title>Adt lab/adjlist and bfs - ประวัติรุ่นแก้ไข</title>
	<link rel="self" type="application/atom+xml" href="http://158.108.32.49/wiki/index.php?action=history&amp;feed=atom&amp;title=Adt_lab%2Fadjlist_and_bfs"/>
	<link rel="alternate" type="text/html" href="http://158.108.32.49/wiki/index.php?title=Adt_lab/adjlist_and_bfs&amp;action=history"/>
	<updated>2026-04-20T13:47:12Z</updated>
	<subtitle>ประวัติรุ่นแก้ไขของหน้านี้ในวิกิ</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>http://158.108.32.49/wiki/index.php?title=Adt_lab/adjlist_and_bfs&amp;diff=57446&amp;oldid=prev</id>
		<title>Jittat เมื่อ 06:50, 1 ธันวาคม 2559</title>
		<link rel="alternate" type="text/html" href="http://158.108.32.49/wiki/index.php?title=Adt_lab/adjlist_and_bfs&amp;diff=57446&amp;oldid=prev"/>
		<updated>2016-12-01T06:50:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;th&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;←รุ่นแก้ไขก่อนหน้า&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;รุ่นแก้ไขเมื่อ 06:50, 1 ธันวาคม 2559&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;แถว 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: &amp;#039;&amp;#039;This is part of [[adt lab]]&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: &amp;#039;&amp;#039;This is part of [[adt lab]]&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;c++&lt;/del&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cpp&lt;/ins&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;vector&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;vector&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jittat</name></author>
		
	</entry>
	<entry>
		<id>http://158.108.32.49/wiki/index.php?title=Adt_lab/adjlist_and_bfs&amp;diff=57445&amp;oldid=prev</id>
		<title>Jittat: หน้าที่ถูกสร้างด้วย &#039;: &#039;&#039;This is part of adt lab&#039;&#039;  &lt;syntaxhighlight lang=&quot;c++&quot;&gt; #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;list&gt;  using namespace ...&#039;</title>
		<link rel="alternate" type="text/html" href="http://158.108.32.49/wiki/index.php?title=Adt_lab/adjlist_and_bfs&amp;diff=57445&amp;oldid=prev"/>
		<updated>2016-12-01T06:49:59Z</updated>

		<summary type="html">&lt;p&gt;หน้าที่ถูกสร้างด้วย &amp;#039;: &amp;#039;&amp;#039;This is part of &lt;a href=&quot;/wiki/index.php/Adt_lab&quot; title=&quot;Adt lab&quot;&gt;adt lab&lt;/a&gt;&amp;#039;&amp;#039;  &amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;vector&amp;gt; #include &amp;lt;list&amp;gt;  using namespace ...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;หน้าใหม่&lt;/b&gt;&lt;/p&gt;&lt;div&gt;: &amp;#039;&amp;#039;This is part of [[adt lab]]&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
#define MAX_N 100000&lt;br /&gt;
&lt;br /&gt;
int n,m;&lt;br /&gt;
vector&amp;lt;int&amp;gt; adj[MAX_N];&lt;br /&gt;
int deg[MAX_N];&lt;br /&gt;
int levels[MAX_N];&lt;br /&gt;
&lt;br /&gt;
void read_input()&lt;br /&gt;
{&lt;br /&gt;
  cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; m;&lt;br /&gt;
  for(int i=0; i&amp;lt;n; i++) {&lt;br /&gt;
    deg[i] = 0;&lt;br /&gt;
  }&lt;br /&gt;
  for(int i=0; i&amp;lt;m; i++) {&lt;br /&gt;
    int u,v;&lt;br /&gt;
    cin &amp;gt;&amp;gt; u &amp;gt;&amp;gt; v;&lt;br /&gt;
&lt;br /&gt;
    adj[u].push_back(v);&lt;br /&gt;
    adj[v].push_back(u);&lt;br /&gt;
&lt;br /&gt;
    deg[u]++;&lt;br /&gt;
    deg[v]++;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void find_levels(int s)&lt;br /&gt;
{&lt;br /&gt;
  list&amp;lt;int&amp;gt; next_level;&lt;br /&gt;
  for(int u=0; u&amp;lt;n; u++) {&lt;br /&gt;
    levels[u] = -1;&lt;br /&gt;
  }&lt;br /&gt;
  next_level.push_back(s);&lt;br /&gt;
  levels[s] = 0;&lt;br /&gt;
  &lt;br /&gt;
  while(! next_level.empty()) {&lt;br /&gt;
    list&amp;lt;int&amp;gt; current_level = next_level;&lt;br /&gt;
    next_level.clear();&lt;br /&gt;
&lt;br /&gt;
    for(list&amp;lt;int&amp;gt;::iterator i = current_level.begin();&lt;br /&gt;
        i != current_level.end(); i++) {&lt;br /&gt;
      int u = *i;&lt;br /&gt;
      &lt;br /&gt;
      for(vector&amp;lt;int&amp;gt;::iterator j = adj[u].begin();&lt;br /&gt;
          j != adj[u].end(); j++) {&lt;br /&gt;
        int v = *j;&lt;br /&gt;
&lt;br /&gt;
        if(levels[v] == -1) {&lt;br /&gt;
          levels[v] = levels[u] + 1;&lt;br /&gt;
          next_level.push_back(v);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
  read_input();&lt;br /&gt;
  find_levels(0);&lt;br /&gt;
  cout &amp;lt;&amp;lt; levels[n-1] &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jittat</name></author>
		
	</entry>
</feed>