title: find length of simple path in graph (cyclic) having maximum value sum ,with the given constraints
body: <p>Given : unweighted undirected graph(cyclic) G(V,E), each vertex has two values (say A and B) which are given and no two adjacent vertices are of same A value.<br/>
  Find the simple path having maximum sum of B values of vertices, with the following constraints: <br/>
  1) This path contains vertices of same A values or it can have at most two different A values(these values have to be alternate because no two adjacent vertices can have same A value) <br/></p>
  
  <p><a href="https://i.stack.imgur.com/BQTvq.png" rel="nofollow noreferrer">fig</a></p>
  
  <p>In the fig. longest simple path starts from vertex 2 and ends at 5, all vertices have at most 2 different values 1 and 2 ,also they are in alternate fashion 1,2,1,2,1 in the path and output the B values sums. <br/>
  Remember : vertex 6 could be the answer if B's value of 6 be 13 because sum of the solution path is 12 only.</p>
  
  <pre><code>int dfs(int source, int parent, int score){
          for each vertex V(V!=p) connected to source:
             if(!vis[V]{
                 if(A[parent]==A[V]){ 
                      recur : dfs(V,source,B[source]+score)
                   }
              }
  
    return score+B[source];
  }
  </code></pre>
  
  <p>It is giving wrong answer.no. of vertices &lt;=1000000</p>