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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:49:23+00:00 2026-06-15T15:49:23+00:00

I have recently discovered graphs and algorithms and am trying to solve a specific

  • 0

I have recently discovered graphs and algorithms and am trying to solve a specific problem involving two different types of vertices: Users and Entities. Details are as follows:

  • The graph is directed
  • I am trying to find all paths from A to B
  • A is always a User
  • B can be a User or an Entity
  • If B is a User, maximum depth for the search is 3 edges
  • If B is an Entity, maximum depth is 2 edges
  • I can not traverse any edges which are outbound from a User, unless the user is A

Although the graph has two types of vertices, it is not bipartite.

So far I have managed to create a graph object which holds a vertex-indexed array of adjacency lists. The adjacency lists are based on linked lists.

I think I require some kind of variation on an All Paths algorithm, but I’m not quite sure. In addition, not sure whether I should be looking at DFS or BFS.

I am working in PHP, which complicates matters, since most examples are in Java. What I’d really like is the pseudo code.

Any ideas? Thanks!

  • 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-15T15:49:24+00:00Added an answer on June 15, 2026 at 3:49 pm

    It sounds like you’re traversing some sort of LDAP implementation. If you need a generic algorithm, just use a DFS, since it’s easier to code. Doing this is overkill though unless the depth will change.

    Most generic way

     dfs(A,B):
         return dfs(A,B,1);
    
     dfs_(u,B,depth):
         if u == B:
              return u;
    
         if (u is User and depth > 3) or (u is Group and depth > 2):
              return None;       
    
         out = [];
         for children of thing:
              return max( dfs_(children,depth+1) ) # take the non-null one
         out.append(u);
         return out;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently discovered that MVC is supposed to have two different flavors, model one
I have just recently discovered the difference between different constructors in GDI+. Going: var
We have recently discovered that when we run a lot of different processes on
I have recently discovered an annoying problem in some large program i am developing;
I recently discovered the lens package on Hackage and have been trying to make
I have recently discovered that I am affected by this bug http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71515.html Well, at
I have recently discovered the ability to use WHERE clauses within indexes in SQL
I recently discovered that when you have a page set to session readonly and
I recently discovered that all Windows 7 machines have an handwriting recognition API within
I have recently read topics about memory fragmentation: How to solve Memory Fragmentation and

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.