Is finding a path with more red vertices than blue vertices NP-hard?Where's the flaw in my algorithm? (Linear program to solve NP-hard problem)Fastest algorithm for shortest path with atmost k edges on a DAG with non-negative edge weights?Algorithm to find whether there is a path (any path) above length X between two verticesLongest path in DAG or finding DAG diameterLongest path in a cyclic, directed and weighted graphFinding path that minimizes largest of the sum of weights of each group in a directed multigraphShortest path with minimal blue edgesColored cliques complexityFind shortest path that goes through at least 5 red edgesFloyd–Warshall algorithm on an undirected graph contains negative weight edgesFind a path from s to t using as few red nodes as possible

How old can references or sources in a thesis be?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Have astronauts in space suits ever taken selfies? If so, how?

Theorems that impeded progress

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

What typically incentivizes a professor to change jobs to a lower ranking university?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Test whether all array elements are factors of a number

Can I make popcorn with any corn?

Mage Armor with Defense fighting style (for Adventurers League bladeslinger)

Dragon forelimb placement

What is the word for reserving something for yourself before others do?

Collect Fourier series terms

LaTeX closing $ signs makes cursor jump

Why do I get two different answers for this counting problem?

Why not use SQL instead of GraphQL?

How does one intimidate enemies without having the capacity for violence?

How do I create uniquely male characters?

Do I have a twin with permutated remainders?

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

To string or not to string

How could an uplifted falcon's brain work?

How does strength of boric acid solution increase in presence of salicylic acid?



Is finding a path with more red vertices than blue vertices NP-hard?


Where's the flaw in my algorithm? (Linear program to solve NP-hard problem)Fastest algorithm for shortest path with atmost k edges on a DAG with non-negative edge weights?Algorithm to find whether there is a path (any path) above length X between two verticesLongest path in DAG or finding DAG diameterLongest path in a cyclic, directed and weighted graphFinding path that minimizes largest of the sum of weights of each group in a directed multigraphShortest path with minimal blue edgesColored cliques complexityFind shortest path that goes through at least 5 red edgesFloyd–Warshall algorithm on an undirected graph contains negative weight edgesFind a path from s to t using as few red nodes as possible













6












$begingroup$


Given a connected, directed graph $G=(V,E)$, vertices $s,t in V$ and a coloring, s.t. $s$ and $t$ are black and all other vertices are either red or blue, is it possible to find a simple path from $s$ to $t$ with more red than blue vertices in polynomial time?



I think it should be possible but our TA said this was NP-hard.



Idea for a solution:



From $G$ create $G'=(V',E')$ as follows:



  • Split all $v in Vsetminus s,t$ in two vertices $v_in$ and $v_out$. $V'$ is made up of the split vertex pairs and $s$ and $t$.


  • For all $e=(u,v) in E$ introduce an edge $(u_out,v_in)$. (For edge $(x,v)$ or $(u,x)$ where $x in s,t$ create edge $(x,v_in)$ or $(u_out,x)$ resp.). Also, introduce an edge $(v_in,v_out)$ for any of the split vertices. So $E'$ contains two types of edges: the ones that correspond to edges from $E$ and the ones that correspond to vertices from $V$.


Now, we introduce weights as follows:




  • $w((v_in,v_out)) = -1$ if the corresponding vertex $v$ was red.


  • $w((v_in,v_out)) = +1$ if the corresponding vertex $v$ was blue.


  • $w(e) = 0$ for all other edges, i.e. the ones that correspond to edges of $G$ rather than vertices.

Now, conduct an algorithm for shortest paths of your choice like Dijkstra, Bellman-Ford,... , check whether the length of the given path is $<0$ and you are done.



Why does this not work? Is it because we may have negative cycles? We could detect those with Bellman Ford but then we'd have to find the desired path with non-efficient means rendering this decision problem NP-hard?
Is there an elegant reduction to show NP-hardness?










share|cite|improve this question









New contributor




Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    6












    $begingroup$


    Given a connected, directed graph $G=(V,E)$, vertices $s,t in V$ and a coloring, s.t. $s$ and $t$ are black and all other vertices are either red or blue, is it possible to find a simple path from $s$ to $t$ with more red than blue vertices in polynomial time?



    I think it should be possible but our TA said this was NP-hard.



    Idea for a solution:



    From $G$ create $G'=(V',E')$ as follows:



    • Split all $v in Vsetminus s,t$ in two vertices $v_in$ and $v_out$. $V'$ is made up of the split vertex pairs and $s$ and $t$.


    • For all $e=(u,v) in E$ introduce an edge $(u_out,v_in)$. (For edge $(x,v)$ or $(u,x)$ where $x in s,t$ create edge $(x,v_in)$ or $(u_out,x)$ resp.). Also, introduce an edge $(v_in,v_out)$ for any of the split vertices. So $E'$ contains two types of edges: the ones that correspond to edges from $E$ and the ones that correspond to vertices from $V$.


    Now, we introduce weights as follows:




    • $w((v_in,v_out)) = -1$ if the corresponding vertex $v$ was red.


    • $w((v_in,v_out)) = +1$ if the corresponding vertex $v$ was blue.


    • $w(e) = 0$ for all other edges, i.e. the ones that correspond to edges of $G$ rather than vertices.

    Now, conduct an algorithm for shortest paths of your choice like Dijkstra, Bellman-Ford,... , check whether the length of the given path is $<0$ and you are done.



    Why does this not work? Is it because we may have negative cycles? We could detect those with Bellman Ford but then we'd have to find the desired path with non-efficient means rendering this decision problem NP-hard?
    Is there an elegant reduction to show NP-hardness?










    share|cite|improve this question









    New contributor




    Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      6












      6








      6





      $begingroup$


      Given a connected, directed graph $G=(V,E)$, vertices $s,t in V$ and a coloring, s.t. $s$ and $t$ are black and all other vertices are either red or blue, is it possible to find a simple path from $s$ to $t$ with more red than blue vertices in polynomial time?



      I think it should be possible but our TA said this was NP-hard.



      Idea for a solution:



      From $G$ create $G'=(V',E')$ as follows:



      • Split all $v in Vsetminus s,t$ in two vertices $v_in$ and $v_out$. $V'$ is made up of the split vertex pairs and $s$ and $t$.


      • For all $e=(u,v) in E$ introduce an edge $(u_out,v_in)$. (For edge $(x,v)$ or $(u,x)$ where $x in s,t$ create edge $(x,v_in)$ or $(u_out,x)$ resp.). Also, introduce an edge $(v_in,v_out)$ for any of the split vertices. So $E'$ contains two types of edges: the ones that correspond to edges from $E$ and the ones that correspond to vertices from $V$.


      Now, we introduce weights as follows:




      • $w((v_in,v_out)) = -1$ if the corresponding vertex $v$ was red.


      • $w((v_in,v_out)) = +1$ if the corresponding vertex $v$ was blue.


      • $w(e) = 0$ for all other edges, i.e. the ones that correspond to edges of $G$ rather than vertices.

      Now, conduct an algorithm for shortest paths of your choice like Dijkstra, Bellman-Ford,... , check whether the length of the given path is $<0$ and you are done.



      Why does this not work? Is it because we may have negative cycles? We could detect those with Bellman Ford but then we'd have to find the desired path with non-efficient means rendering this decision problem NP-hard?
      Is there an elegant reduction to show NP-hardness?










      share|cite|improve this question









      New contributor




      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      Given a connected, directed graph $G=(V,E)$, vertices $s,t in V$ and a coloring, s.t. $s$ and $t$ are black and all other vertices are either red or blue, is it possible to find a simple path from $s$ to $t$ with more red than blue vertices in polynomial time?



      I think it should be possible but our TA said this was NP-hard.



      Idea for a solution:



      From $G$ create $G'=(V',E')$ as follows:



      • Split all $v in Vsetminus s,t$ in two vertices $v_in$ and $v_out$. $V'$ is made up of the split vertex pairs and $s$ and $t$.


      • For all $e=(u,v) in E$ introduce an edge $(u_out,v_in)$. (For edge $(x,v)$ or $(u,x)$ where $x in s,t$ create edge $(x,v_in)$ or $(u_out,x)$ resp.). Also, introduce an edge $(v_in,v_out)$ for any of the split vertices. So $E'$ contains two types of edges: the ones that correspond to edges from $E$ and the ones that correspond to vertices from $V$.


      Now, we introduce weights as follows:




      • $w((v_in,v_out)) = -1$ if the corresponding vertex $v$ was red.


      • $w((v_in,v_out)) = +1$ if the corresponding vertex $v$ was blue.


      • $w(e) = 0$ for all other edges, i.e. the ones that correspond to edges of $G$ rather than vertices.

      Now, conduct an algorithm for shortest paths of your choice like Dijkstra, Bellman-Ford,... , check whether the length of the given path is $<0$ and you are done.



      Why does this not work? Is it because we may have negative cycles? We could detect those with Bellman Ford but then we'd have to find the desired path with non-efficient means rendering this decision problem NP-hard?
      Is there an elegant reduction to show NP-hardness?







      complexity-theory graphs






      share|cite|improve this question









      New contributor




      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|cite|improve this question









      New contributor




      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|cite|improve this question




      share|cite|improve this question








      edited 2 days ago









      xskxzr

      4,18921033




      4,18921033






      New contributor




      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Apr 3 at 12:17









      Valerie PoulainValerie Poulain

      332




      332




      New contributor




      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Valerie Poulain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          8












          $begingroup$

          Your solution does not work because Dijkstra and Bellman-Ford cannot interpret "simple path" feature. And they will indeed fall in any negative cycle.



          I think the best to show NP-completeness, is to use the Hamiltonian path problem. Let's take a graph $G'$ of $N$ red vertices.



          Then you build a graph $G$, adding $s$, $t$ and $N-1$ blue vertices to $G'$. You first chain with edges all the blues vertices from the source to the last blue one ($s$->$b_1$->$b_2$->...->$b_N-1$). Then you put edges from $b_N-1$ to every red vertex and an edge from every red vertex to $t$.



          So a single path from $s$ to $t$ passes necessarly through all blue nodes ($N-1$) and then have to pass to all red nodes ($N$) to answer to



          Is there a simple path in $G$ from $s$ to $t$ with more red than blue vertices ?



          which is thus like answer to:



          Is there an Hamiltonian path in $G'$



          So your problem is indeed NP-complete.






          share|cite|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
            $endgroup$
            – Valerie Poulain
            Apr 3 at 14:02






          • 1




            $begingroup$
            Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
            $endgroup$
            – Vince
            Apr 3 at 14:26






          • 2




            $begingroup$
            Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
            $endgroup$
            – Quuxplusone
            Apr 3 at 18:45







          • 1




            $begingroup$
            @Quuxplusone you are right I edit to make it clearer.
            $endgroup$
            – Vince
            2 days ago










          • $begingroup$
            @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
            $endgroup$
            – j_random_hacker
            2 days ago











          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "419"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Valerie Poulain is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f106420%2fis-finding-a-path-with-more-red-vertices-than-blue-vertices-np-hard%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8












          $begingroup$

          Your solution does not work because Dijkstra and Bellman-Ford cannot interpret "simple path" feature. And they will indeed fall in any negative cycle.



          I think the best to show NP-completeness, is to use the Hamiltonian path problem. Let's take a graph $G'$ of $N$ red vertices.



          Then you build a graph $G$, adding $s$, $t$ and $N-1$ blue vertices to $G'$. You first chain with edges all the blues vertices from the source to the last blue one ($s$->$b_1$->$b_2$->...->$b_N-1$). Then you put edges from $b_N-1$ to every red vertex and an edge from every red vertex to $t$.



          So a single path from $s$ to $t$ passes necessarly through all blue nodes ($N-1$) and then have to pass to all red nodes ($N$) to answer to



          Is there a simple path in $G$ from $s$ to $t$ with more red than blue vertices ?



          which is thus like answer to:



          Is there an Hamiltonian path in $G'$



          So your problem is indeed NP-complete.






          share|cite|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
            $endgroup$
            – Valerie Poulain
            Apr 3 at 14:02






          • 1




            $begingroup$
            Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
            $endgroup$
            – Vince
            Apr 3 at 14:26






          • 2




            $begingroup$
            Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
            $endgroup$
            – Quuxplusone
            Apr 3 at 18:45







          • 1




            $begingroup$
            @Quuxplusone you are right I edit to make it clearer.
            $endgroup$
            – Vince
            2 days ago










          • $begingroup$
            @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
            $endgroup$
            – j_random_hacker
            2 days ago















          8












          $begingroup$

          Your solution does not work because Dijkstra and Bellman-Ford cannot interpret "simple path" feature. And they will indeed fall in any negative cycle.



          I think the best to show NP-completeness, is to use the Hamiltonian path problem. Let's take a graph $G'$ of $N$ red vertices.



          Then you build a graph $G$, adding $s$, $t$ and $N-1$ blue vertices to $G'$. You first chain with edges all the blues vertices from the source to the last blue one ($s$->$b_1$->$b_2$->...->$b_N-1$). Then you put edges from $b_N-1$ to every red vertex and an edge from every red vertex to $t$.



          So a single path from $s$ to $t$ passes necessarly through all blue nodes ($N-1$) and then have to pass to all red nodes ($N$) to answer to



          Is there a simple path in $G$ from $s$ to $t$ with more red than blue vertices ?



          which is thus like answer to:



          Is there an Hamiltonian path in $G'$



          So your problem is indeed NP-complete.






          share|cite|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
            $endgroup$
            – Valerie Poulain
            Apr 3 at 14:02






          • 1




            $begingroup$
            Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
            $endgroup$
            – Vince
            Apr 3 at 14:26






          • 2




            $begingroup$
            Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
            $endgroup$
            – Quuxplusone
            Apr 3 at 18:45







          • 1




            $begingroup$
            @Quuxplusone you are right I edit to make it clearer.
            $endgroup$
            – Vince
            2 days ago










          • $begingroup$
            @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
            $endgroup$
            – j_random_hacker
            2 days ago













          8












          8








          8





          $begingroup$

          Your solution does not work because Dijkstra and Bellman-Ford cannot interpret "simple path" feature. And they will indeed fall in any negative cycle.



          I think the best to show NP-completeness, is to use the Hamiltonian path problem. Let's take a graph $G'$ of $N$ red vertices.



          Then you build a graph $G$, adding $s$, $t$ and $N-1$ blue vertices to $G'$. You first chain with edges all the blues vertices from the source to the last blue one ($s$->$b_1$->$b_2$->...->$b_N-1$). Then you put edges from $b_N-1$ to every red vertex and an edge from every red vertex to $t$.



          So a single path from $s$ to $t$ passes necessarly through all blue nodes ($N-1$) and then have to pass to all red nodes ($N$) to answer to



          Is there a simple path in $G$ from $s$ to $t$ with more red than blue vertices ?



          which is thus like answer to:



          Is there an Hamiltonian path in $G'$



          So your problem is indeed NP-complete.






          share|cite|improve this answer











          $endgroup$



          Your solution does not work because Dijkstra and Bellman-Ford cannot interpret "simple path" feature. And they will indeed fall in any negative cycle.



          I think the best to show NP-completeness, is to use the Hamiltonian path problem. Let's take a graph $G'$ of $N$ red vertices.



          Then you build a graph $G$, adding $s$, $t$ and $N-1$ blue vertices to $G'$. You first chain with edges all the blues vertices from the source to the last blue one ($s$->$b_1$->$b_2$->...->$b_N-1$). Then you put edges from $b_N-1$ to every red vertex and an edge from every red vertex to $t$.



          So a single path from $s$ to $t$ passes necessarly through all blue nodes ($N-1$) and then have to pass to all red nodes ($N$) to answer to



          Is there a simple path in $G$ from $s$ to $t$ with more red than blue vertices ?



          which is thus like answer to:



          Is there an Hamiltonian path in $G'$



          So your problem is indeed NP-complete.







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited 2 days ago

























          answered Apr 3 at 12:56









          VinceVince

          71328




          71328







          • 1




            $begingroup$
            Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
            $endgroup$
            – Valerie Poulain
            Apr 3 at 14:02






          • 1




            $begingroup$
            Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
            $endgroup$
            – Vince
            Apr 3 at 14:26






          • 2




            $begingroup$
            Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
            $endgroup$
            – Quuxplusone
            Apr 3 at 18:45







          • 1




            $begingroup$
            @Quuxplusone you are right I edit to make it clearer.
            $endgroup$
            – Vince
            2 days ago










          • $begingroup$
            @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
            $endgroup$
            – j_random_hacker
            2 days ago












          • 1




            $begingroup$
            Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
            $endgroup$
            – Valerie Poulain
            Apr 3 at 14:02






          • 1




            $begingroup$
            Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
            $endgroup$
            – Vince
            Apr 3 at 14:26






          • 2




            $begingroup$
            Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
            $endgroup$
            – Quuxplusone
            Apr 3 at 18:45







          • 1




            $begingroup$
            @Quuxplusone you are right I edit to make it clearer.
            $endgroup$
            – Vince
            2 days ago










          • $begingroup$
            @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
            $endgroup$
            – j_random_hacker
            2 days ago







          1




          1




          $begingroup$
          Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
          $endgroup$
          – Valerie Poulain
          Apr 3 at 14:02




          $begingroup$
          Neat, thanks. So if I wanted to formally prove $DHP preceq ProblemAbove$ where I have to start with an instance $G,s,t$ for the Hamiltonian Path and map it to an instance $G',s',t'$ of this problem, could I do the following: Color all existing vertices red, add $|Vsetminuss,t|-1$ blue vertices and connect them in a chain $(b_1)rightarrow ldots rightarrow(b_n)$. Add an edge $(s,b_1)$, and for each $(s,v)$ in $G$ an edge $(b_n,v)$ in $G'$, the rest stays as it is.
          $endgroup$
          – Valerie Poulain
          Apr 3 at 14:02




          1




          1




          $begingroup$
          Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
          $endgroup$
          – Vince
          Apr 3 at 14:26




          $begingroup$
          Yes I am not very familiar with NP-completeness demonstration but this way to present it is clearly better. I would nevertheless start with an instance of $G$ without $s$ & $t$ as initial Hamiltonian path problem has no specific vertex.
          $endgroup$
          – Vince
          Apr 3 at 14:26




          2




          2




          $begingroup$
          Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
          $endgroup$
          – Quuxplusone
          Apr 3 at 18:45





          $begingroup$
          Upvoted for (I think) correctness; but this argument would be WAY easier to understand if you STARTED with the arbitrary graph $G'$ and then embedded it within the specially constructed $G$. Right now the reduction is hiding entirely in the single sentence "Finally, you put any number of edges between red vertices," which I missed on my first reading. "Any number of edges" is code for "you pick any arbitrary graph $G'$ whose Hamiltonian path you'd like to discover, and embed it in there." That's what makes this a valid reduction.
          $endgroup$
          – Quuxplusone
          Apr 3 at 18:45





          1




          1




          $begingroup$
          @Quuxplusone you are right I edit to make it clearer.
          $endgroup$
          – Vince
          2 days ago




          $begingroup$
          @Quuxplusone you are right I edit to make it clearer.
          $endgroup$
          – Vince
          2 days ago












          $begingroup$
          @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
          $endgroup$
          – j_random_hacker
          2 days ago




          $begingroup$
          @ValeriePoulain: Vince is right that starting and ending vertices are not given for the usual HP problem, but if they are given, your reduction needs a slight tweak: You must insert a chain of $|V setminus s, t|-1$ blue vertices in a line along each edge between $s$ and any other red vertex. This is to prevent, e.g., a single edge from $s$ to some red vertex from being a valid solution to the constructed instance.
          $endgroup$
          – j_random_hacker
          2 days ago










          Valerie Poulain is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Valerie Poulain is a new contributor. Be nice, and check out our Code of Conduct.












          Valerie Poulain is a new contributor. Be nice, and check out our Code of Conduct.











          Valerie Poulain is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Computer Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f106420%2fis-finding-a-path-with-more-red-vertices-than-blue-vertices-np-hard%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company