<p>You have an undirected, connected graph of <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. You are given an array <code>graph</code> where <code>graph[i]</code> is a list of all the nodes connected with node <code>i</code> by an edge.</p>

<p>Return <em>the length of the shortest path that visits every node</em>. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/12/shortest1-graph.jpg" style="width: 222px; height: 183px;" />
<pre>
<strong>Input:</strong> graph = [[1,2,3],[0],[0],[0]]
<strong>Output:</strong> 4
<strong>Explanation:</strong> One possible path is [1,0,2,0,3]
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/12/shortest2-graph.jpg" style="width: 382px; height: 222px;" />
<pre>
<strong>Input:</strong> graph = [[1],[0,2,4],[1,3,4],[2],[1,2]]
<strong>Output:</strong> 4
<strong>Explanation:</strong> One possible path is [0,1,4,2,3]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == graph.length</code></li>
	<li><code>1 &lt;= n &lt;= 12</code></li>
	<li><code>0 &lt;= graph[i].length &lt;&nbsp;n</code></li>
	<li><code>graph[i]</code> does not contain <code>i</code>.</li>
	<li>If <code>graph[a]</code> contains <code>b</code>, then <code>graph[b]</code> contains <code>a</code>.</li>
	<li>The input graph is always connected.</li>
</ul>

class Solution {
public:
    //int shortestPathLength(vector<vector<int>>& graph) {
int shortestPathLength(vector<vector<int>> b){
    int c=1;
    int temp0=c;
    for(int e=1;e<b.size();e++){
        c=c * 2;
        temp0=temp0+c;
    }
    //cout<<c<<" ";
    //cout<<temp0<<" ";
    vector<vector<int>> e;
    for(int temp12=0;temp12<b.size();temp12++){
        vector<int> temp2;
        for(int temp18=0;temp18<temp0+1;temp18++){
            temp2.push_back(0);
        }
        //cout<<temp2.size()<<" ";
        e.push_back(temp2);
    }
    //cout<<e[1][12]<<" ";
    queue<pair<int,string>> temp12;
    for(int temp0=0;temp0<b.size();temp0++){
        pair<int,string> temp18;
        temp18.first=temp0;
        string temp28;
        for(int temp48=0;temp48<b.size();temp48++){
            temp28=temp28+'0';
        }
        temp18.second=temp28;
        temp18.second[temp0]='1';
        temp12.push(temp18);
    }
    int temp48=0;
    int temp198=1;
    while(temp12.size()!=0){
        int temp18=temp12.size();
        for(int temp28=0;temp28<temp18;temp28++){
        pair<int,string> temp72=temp12.front();
        temp12.pop();
        int temp172=0;
        int temp192=1;
        for(int temp78=temp72.second.size()-1;temp78>=0;temp78--){
            if(temp72.second[temp78]=='1'){
                temp172=temp172+temp192;
            }
            temp192=temp192 * 2;
        }
        if(temp172==temp0){
            temp198=0;
            break;
        }
        //cout<<temp172<<" ";
        //cout<<temp72.first<<" ";
        //cout<<e[0][1]<<" ";
        e[temp72.first][temp172]=1;
        for(int temp78=0;temp78<b[temp72.first].size();temp78++){
            int temp92=0;
            int temp128=1;
            for(int temp98=temp72.second.size()-1;temp98>=0;temp98--){
                if(temp98==b[temp72.first][temp78] || temp72.second[temp98]=='1'){
                    temp92=temp92+temp128;
                }
                temp128=temp128 * 2;
            }
            //cout<<temp92<<" ";
            //cout<<b[temp72.first][temp78]<<" ";
            //cout<<e[1][12]<<" ";
            if(e[b[temp72.first][temp78]][temp92]==0){
                pair<int,string> temp148;
                temp148.first=b[temp72.first][temp78];
                temp148.second=temp72.second;
                temp148.second[b[temp72.first][temp78]]='1';
                temp12.push(temp148);
                e[b[temp72.first][temp78]][temp92]=1;
            }
        }
        }
        //temp48=temp48+1;
        if(temp198==0){
            break;
        }
        temp48=temp48+1;
    }
    return temp48;
    }
};
28558