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

          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020