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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:25:19+00:00 2026-06-04T20:25:19+00:00

How can I find all way to go end in undirected graph ? Graph

  • 0

How can I find all way to go end in undirected graph ?

Graph :

    Node : S, Y, F, T                visualization :    S ----- Y ---- T
    Edge : S --- Y                                       \     /
           Y --- F                                        \   /
           S --- F                                         \ /
           Y --- T                                          F


Assume that

       Start   S 
       Finish  F

       after run   go 

       result will be :

              S F
              S Y F

I do not want visit one node more than once. If I visit, this problem become one of NP problems.

EDIT:

input can be any form

example:

       edge (S,Y).     OR          edge (Y,S).
       edge (Y,F).                 edge (F,Y).
       edge (S,F).                 edge (F,S).
       edge (Y,T).                 edge (T,Y).

BUT OUTPUT MUST BE SAME

  • 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-04T20:25:20+00:00Added an answer on June 4, 2026 at 8:25 pm

    Keep a trace of the visited nodes and exclude those when adding the possible destinations in the next step.

    I changed a few edges and added one, to make sure it also works when edges are listed in the ‘wrong’ order for going from S to F.

    edge('S','Y').    visualization:    S -- Y -- T
    edge('F','Y').                     / \  /
    edge('S','F').                    /   \/
    edge('Y','T').                   A --- F
    edge('A','S').
    edge('F','A').
    

    In prolog this should roughly look like this:

    pathBetween(A,A,_):- !, fail.
    pathBetween(S,F,Visited) :- (edge(S,F) ; edge(F,S)),
        append(Visited,[S,F],L),
        write(L).
    pathBetween(S,F,Visited) :-
        (   edge(S,A) ; edge(A,S)  ),
        not(member(A,Visited)),
        pathBetween(A,F,[S|Visited]).
    

    You can use ; to manually find all the solutions, or findall.

    ?- findall(Visited, pathBetween('S', 'F', []), _).
    [S,F][S,Y,F][S,A,F]
    true.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way I can find all active spies in sinon.js? I'd like
Is there a way I can find out all changes to memory by a
I can't seem to find a way to fix this problem. All I'm doing
I am wondering how i can find all rows that have the same ID
How i can find all the windows created by a particular process using c#?
Is there a place where I can find all the keycodes for keys on
Can we find all tables in the msaccess using sql . as we do
how can i find all the anchor tags with source pdf $string=hello this is
How can I find all column values in a column which have trailing spaces?
How can i find all subsets of a set using c#? here set is

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.