Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was looking at this.

If I were just given a list that contained the number of edges (graph), pair of edges, a origin and a destination, how would I figure out if there is or isn't a path?

I have some idea, but just need a bit of help in terms of starting in scheme.

(is_it_a_path? '(4 ((1 2) (2 3) (3 4) (2 4))) 1 4) ; returns true 

(is_it_a_path? '(3 ((1 2) (2 3) (3 1))) 2 3)       ; also returns true 

In the following 4 is the number of vertices, (1 2)... and so are are the edges and 1 is the start and 4 is the end. Basically from these you are looking at whether there is a path from 1 to 4 in the following defined graph. I hope that can clarify what I mean.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
148 views
Welcome To Ask or Share your Answers For Others

1 Answer

Did you see John Clements's earlier response to look at How to Design Programs? It has a Chapter on how to design programs that deal with graphs.

As a meta-answer: the question you're asking, about how to get started on a problem that you're unfamiliar with, is the heart of the HtDP book. Have you looked at it? It's essentially an adaptation of Polya's How To Solve It, but tailored for writing computer programs rather than math proofs. The Second edition draft may be easier to read.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...