title: In Maze which have N keys what should i do to find shortest path with BFS?
body: <p>Now, I'm trying to implement finding shortest path program with Python
  In my case, Maze has N keys and i should find all keys to escape from Maze</p>
  <p>Example) start Point S, Key1 , Key2, Finish point F
  We have 2 paths</p>
  <ol>
  <li>S -&gt; Key1 -&gt; Key2 -&gt; F</li>
  <li>S -&gt; Key2 -&gt; Key1 -&gt; F</li>
  </ol>
  <p>If it has 3 Keys then, it becomes hard</p>
  <ol>
  <li>S-&gt; Key1 -&gt; Key2 -&gt;Key3 -&gt;F</li>
  <li>S-&gt; Key1 -&gt; Key3 -&gt;Key2 -&gt;F</li>
  <li>S-&gt; Key2 -&gt; Key3 -&gt;Key1 -&gt;F</li>
  <li>S-&gt; Key2 -&gt; Key1 -&gt;Key3 -&gt;F</li>
  <li>S-&gt; Key3 -&gt; Key1 -&gt;Key2 -&gt;F</li>
  <li>S-&gt; Key3 -&gt; Key2 -&gt;Key1 -&gt;F</li>
  </ol>
  <p>Anyway, To solve this, I make each visit matrix to get all distances From Each node(S,F,Key)
  But, I don't know what should I do from now on.</p>
  <p><strong>Please Help Me
  How can I get shortest path in this case?</strong></p>