Re: graph path searching
- From: "Martin Sondergaard" <nobody@xxxxxxxxxxx>
- Date: Thu, 24 Nov 2005 12:46:34 -0000
<timasmith@xxxxxxxxxxx> wrote in message
news:1132797570.728092.131130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> So what I have done so far is removed the complexity of a weighted
> graph and tackled it by the following.
>
> So suppose I have n nodes where n>1 in an undirected unweighted graph.
>
> I get the shortest path between the first 2 nodes using bfs (code
> below) and add to a nodelist called listnode
>
> foreach node in remaining nodes
> foreach node2 in listnode
> dist = shortestpath(node,node2)
> if dist < mindist then mindist = dist
>
> So this seems to work - but I am not sure whether it meets the goal of
> minimum number of nodes in total?
>
>
>
> search(X,Y,Route) :- search(X,Y,[[X]],Route).
> search(X,X,[[X]],[X]).
> search(X,Y,[[Y|Path]|_],[Y|Path]).
> search(X,Y,[Path|Paths],Route) :-
> expand(Path,Alternatives),
> append(Paths,Alternatives,Paths1),
> search(X,Y,Paths1,Route).
"X" and "Y" are unused.
As far as I can tell, they are never instantiated,
never given values, except by accident.
So you can remove them from this code.
--
Martin Sondergaard,
London.
.
- References:
- graph path searching
- From: timasmith
- Re: graph path searching
- From: Martin Sondergaard
- Re: graph path searching
- From: timasmith
- graph path searching
- Prev by Date: Prolog and the web
- Next by Date: Re: database use in SWI-Prolog
- Previous by thread: Re: graph path searching
- Next by thread: java calling prolog
- Index(es):
Relevant Pages
|
|