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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:54:38+00:00 2026-06-09T11:54:38+00:00

Given a graph G, a node n and a length L, I’d like to

  • 0

Given a graph G, a node n and a length L, I’d like to collect all (non-cyclic) paths of length L that depart from n.

Do you have any idea on how to approach this?

By now, I my graph is a networkx.Graph instance, but I do not really care if e.g. igraph is recommended.

Thanks a lot!

  • 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-09T11:54:39+00:00Added an answer on June 9, 2026 at 11:54 am

    I would just like to expand on Lance Helsten’s excellent answer:

    The depth-limited search searches for a particular node within a certain depth (what you’re calling the length L), and stops when it finds it. If you will take a look at the pseudocode in the wiki link in his answer, you’ll understand this:

    DLS(node, goal, depth) {
      if ( depth >= 0 ) {
        if ( node == goal )
          return node
    
        for each child in expand(node)
          DLS(child, goal, depth-1)
      }
    }
    

    In your case, however, as you’re looking for all paths of length L from a node, you will not stop anywhere. So the pseudocode must be modified to:

    DLS(node, depth) {
        for each child in expand(node) {
          record paths as [node, child]
          DLS(child, depth-1)
        }
    }
    

    After you’re done with recording all the single-link paths from successive nests of the DLS, just take a product of them to get the entire path. The number of these gives you the number of paths of the required depth starting from the node.

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

Sidebar

Related Questions

Given a node in a graph that is reachable, how do you find all
Given a node x in an undirected graph that is known to be part
Given a graph and a destination node, how do you find all the shortest
I have a dependency graph that I have represented as a Map<Node, Collection<Node>> (in
Given a directed graph, the goal is to combine the node with the nodes
In the Lemon C++ Graph Library, given a node in an undirected graph say,
Given graph, how could i represent it using adj matrix?. I have read lots
We are given a graph G(V,E) with N nodes (Numbered from 0 to N-1)
I want to use graphviz in order to draw for a given graph all
Given an undirected graph in which each node has a Cartesian coordinate in space

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.