Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:58:48+00:00 2026-06-02T04:58:48+00:00

Given G, a directed graph, is there a path (not necessarily a simple path)

  • 0

Given G, a directed graph, is there a path (not necessarily a simple path) that goes through all the vertices in G?

I first need to examine what happens in an acyclic graph and in a strongly-connected graph, and then to find a solution for a general graph, using the graph of the strongly connected components.

So far I have figured out that for a strongly connected graph there is always a path. For an acyclic graph, if there is more than one source a path will never exist. Also, if there is a vertex for which D out is greater than 1, a path will never exist.

The problem is, I’m not sure that last one is right, and if it’s wrong, my algorithm is wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:58:49+00:00Added an answer on June 2, 2026 at 4:58 am

    The last assumption is not true, for example have a look at the graph G = (V,E), where E = {(v_i,v_j) | i < j } The graph is obviously a DAG. so finding the maximal strongly connected component won’t change the graph. Also – the graph has a hamiltonian path, however d_out(v_1) > 1 [assuming |V| > 3].

    However – you are on the right track.

    Algorithm in high level pseudo code:

    1. find Maximal Strongly Connected Components in the graph – the
      resulting graph is a DAG.
    2. Use topological sort on the resulting graph1.
    3. Check if the ordered sorting creates a hamiltonian path
    4. if it is – return true, else return false

    Claim:

    A path with all vertices exists if and only if the DAG representing
    the MSCC of the graph has hamiltonian path

    Proof of claim:

    <-

    if there is a hamiltonian path – then such a path is trivial, for each MSCC – the path goes through all vertices, and then to the out edge that is representing the our edge that was chosen in the hamiltonian path in the MSCC graph.

    ->

    If such a path exists, let it be v0->v1->...vm.

    Let’s denote V_i the maximal strongly connected component in which v_i lays.

    Now, for the path in the original graph v0->v1->...->vm, there is also a path in the MSCC graph2: V_0->V_1->...->V_m.

    Note that if V_i appears twice [or more] in the above path – the two occurances are adjacent to each other, otherwise the MSCC found is not maximal because if V_i->V_k->...->V_i is feasible path – then V_i and V_k are not maximal, since you can unite them into one bigger SCC.

    Now, for each V_i collapse all occurances of it into one, and you get yourself a path – where each V_i appears at most once [we just showed why], and exactly one [since every v_i was on the original path and we did not remove MSCC’s completely – just collapsed them].

    Thus – the generated path is a hamiltonian path in the MSCC graph.

    Proof of correctness of the suggested algrotithm:

    Since we showed hamiltonian path in MSCC graph exists if and only if there exists a requested path in the original graph – then:

    ->

    The algorithm returned true -> The algorithm found a Hamiltonian path in the DAG -> There is a Hamiltonian Path in the Dag [foot-note 1] -> There is a path as requested in the original graph.

    <-

    The algorithm returned false -> The algorithm did not find a Hamiltonian pat in the DAG -> There is no hamiltonian path in the DAG [foot-note 1] -> There is no path as requested in the original path.

    Q.E.D.


    1: in a DAG, there is a unique topological sort if there exists a hamiltonian path, and if there is a hamiltonian path – it is the order of the vertices in the topological sort. Thus, in a DAG – finding a hamiltonian path is easy.

    2: Actually, it is a bit modification, V_i->V_i is not really an edge on the MSCC, graph but for now let’s denote it as one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a directed graph, I need to find the minimum set of vertices from
Given a directed, connected graph with only positive edge weights, are there faster algorithms
Given a directed graph, the goal is to combine the node with the nodes
Given the following problem : Given the directed graph G=(V,E) with the weight function
Suppose I had this Directed Acyclic Graph (DAG) , where there is a directed
I have defined a C#-class, that shall be the elements of a directed graph
Given a directed graph with weighted edges, what algorithm can be used to give
Let's say we have a fully connected directed graph G . The vertices are
I've a directed unweighted graph. Number of nodes and all links between nodes are
Given an directed unweighted acylic graph, I am trying to adapt Floyd-Warshall algorithm to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.