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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:55:26+00:00 2026-05-21T14:55:26+00:00

Example: I have 20 persons as object, and every person knows 0-n others. The

  • 0

Example: I have 20 persons as object, and every person knows 0-n others. The direction of the link matters! A person A might know B, but B might not know A. It’s a directed graph.

Edit: For simplification, my node objects (in this case Person objects) are able to store arbitrary information. I know this is not the best design but for now that would be fine.

So in the worst case everyone is connected with everyone else, everyone knows everyone else.
This is no real use case but I want to write a test for this to learn and play around. In a productive environment the number of objects would be limited to about 20, but the ways in which those objects are connected to eachother are unlimited.

This illustrates the problem in a simplified way:
graph thanks to source

Given a specific person as starting point, I want to walk through the whole graph and examine every possible path exactly once without getting stuck in an infinite loop.

Let’s imagine person A knows B, who knows C, and who knows A. The output might be:

A knows B knows C knows A (ok but we don’t want to end in an infinite loop so we stop here)
A knows C knows A
A knows T knows R knows V

This would be stupid and must be eliminated:
A knows B knows C knows A knows C knows A knows T knows R knows V …

I do have a couple of crazy ideas how to tackle this problem. But…

Question) Must I do that with an Iterative deepening depth-first search (IDDFS)?


Jon was so kind to point out DFS on Wikipedia

I’m stuck with this part in the article:
wikipedia

a depth-first search starting at A,
assuming that the left edges in the
shown graph are chosen before right
edges, and assuming the search
remembers previously-visited nodes and
will not repeat them (since this is a
small graph), will visit the nodes in
the following order: A, B, D, F, E, C,
G. The edges traversed in this search
form a Trémaux tree, a structure with
important applications in graph
theory.

specifically this note:

“(since this is a small graph)”

OK so what if this is a huge 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-05-21T14:55:26+00:00Added an answer on May 21, 2026 at 2:55 pm

    Your data structure is indeed a graph.

    I hate to provide such a bare answer, but the question is so basic that Graph Traversal on Wikipedia is more than adequate. The two basic approaches are explained and there is also pseudocode.

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

Sidebar

Related Questions

Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
Example-I have a person class Public Class Person Private _fname As String Public Property
For example I have a simple class like public class Person{ public int Age
I have for example, a DB with the following entity and relation structure: [Person]
I have models (simplified example): class Group(models.Model): name = models.CharField(max_length = 32) class Person(models.Model):
I have a Struts + Velocity structure like for example, a Person class, whose
the title might be too generic, but I have a very specific question about
Study case: If I have for example The library object. In the library are
Say, I have a Person object list called people: public class Person { public
I have object has XML as a string. For example I have a 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.