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 3871328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:48:48+00:00 2026-05-19T21:48:48+00:00

I am looking the number of unique x length paths through a graph starting

  • 0

I am looking the number of unique x length paths through a graph starting at a particular node.

However I have a restriction that no node is visited more than once on any path.


For example take the following graph:
enter image description here

If I am after the number of 3 length paths starting at 5.

The answer would be 9.

5 -> 2 -> 1 -> 3
5 -> 2 -> 4 -> 3
5 -> 2 -> 4 -> 7
5 -> 4 -> 2 -> 1
5 -> 4 -> 3 -> 1
5 -> 4 -> 7 -> 6
5 -> 6 -> 7 -> 4
5 -> 7 -> 4 -> 2
5 -> 7 -> 4 -> 3

Note I am only concerted with the answer (9) not the specific paths.


I have tried using an adjacency matrix to the power of x to give the number of paths, but I cannot work out how to account for unique node restriction.

I have also tried using a depth-first search but the amount of nodes and size of x makes this infeasible.


EDIT: Confused DFS with BFS (Thank you Nylon Smile & Nikita Rybak).

  • 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-05-19T21:48:48+00:00Added an answer on May 19, 2026 at 9:48 pm

    This is NP-Hard.

    Reduction from Hamiltonian Path.

    Given a graph whose Hamiltonian Path existence we need to check…

    Run your algorithm for each vertex, with a path length n-1. Any non-zero return corresponds to Hamiltonian path and vice versa.

    So basically, if you find a polynomial time algorithm to solve your problem, then you have a polynomial time algorithm to solve the Hamiltonian Path problem, effectively proving P=NP!

    Note: This assumes x is an input.

    If you x was fixed (i.e. independent of the number of vertices in the graph), then you have O(n^x) time algorithms, which is in P, but still pretty impractical for medium sized x.

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

Sidebar

Related Questions

What I am looking for: I have a number of divs that are used
I'm looking at files that all have a different version number that starts at
I am looking for a way to generate pseudo random number sequences that will
I'm looking for a way of mapping a uid (unique number representing a system
I am looking for an efficient way to detect the number of unique values
I'm looking for a fast PRNG so that I can quickly create (semi)unique IDs
I'm looking for a good algorithm that can give me the unique edges from
I'm looking for the best way to basically get a unique number (guaranteed, not
I'm looking for a hash function that I can use to give uniform unique
We are currently looking for a way to find the number of unique request

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.