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

The Archive Base Latest Questions

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

I have a graph which consists of nodes and I need a fast algorithm

  • 0

I have a graph which consists of nodes and I need a fast algorithm that generates a random path between two nodes. I designed several algorithms from scratch for this but can’t seem to get it right.

Either the algorithm gets stuck in loops, or when I keep record of the visited nodes it sometimes gets stuck between visited nodes. Another problem I encountered is that my algorithm was too unstable in performance.

So my question is; does anyone know a fast and stable algorithm for a random path between two reachable nodes in an undirected graph?

  • 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-02T09:48:36+00:00Added an answer on June 2, 2026 at 9:48 am

    Let your graph be G=(V,E). Create a subset U of V such that U = { u | there is a path from u to the target }.

    • Note that finding this subset U is easy – and can be done in linear
      time using DFS or BFS on the reversed edges from the
      target.

    Using this subset, create a graph G'=(U,E') where U is defined above and E' = E [intersection] UxU [The same edges, but applied only on vertices in U].

    Run randomized (choosing which vertex to explore next on random) DFS on G' until you reach the target.

    • Note – the idea is to find a path – not necesseraly simple, and thus you shouldn’t maintain a visited set.
    • You might add a “break rule” that if you reach a certain depth, you will seek the target – unrandomised, to avoid infinite loops in circles.
    • Perofrmance is expected to be varying, since it is linear in the length of the found path, which might be very long or very short…
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm given a graph which can have more than one arch between 2 nodes.
I have a graph-theoretic (which is also related to combinatorics) problem that is illustrated
I have a graph which is essentially an ArrayList of Nodes, each of which
I have a networkx graph which contains nodes whose positions in the graph are
I have a weighted, directed graph which is dense with around 20,000 nodes. Given
I have a graph which contains an unknown number of disconnected subgraphs. What's a
I have made a sample application which constructs a filter graph to capture audio
I have a graph with n nodes as an adjacency matrix . Is it
I have a graph library that I use to plot some data. This data
I have a domain model that consists of fairly large object graphs, where domain

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.