Manuel Weindorf wrote: > > Question: How to create a array from a list ?? Eclipse uses the convention that an array is just a structure with the funny functor '[]', for example: WeekDayArray = [](mo,tu,we,th,fr,sa,su) You can therefore use the =../2 predicate to convert between lists and these arrays: array_list(Array, List) :- Array =.. [[]|List]. > how can I create a graph (of the library(graph_algorithms)) from the > following facts > > node( 1, some, attributes, ... ). > node( 2, some, attributes, ...). > etc. > > edge( 1, 1, 2 ). % that means -> edge( EdgeID, FromNode, ToNode ). > edge( 2, 2, 3 ). > etc. > > I guess I should use the 'make_graph_symbolic()' predicate, but I couldn't > figure aout hoe to create the nodes_arrayaout of my facts :-( Since your nodes are already numbered from 1..N, you can use the simpler predicate make_graph/3, which means you don't need the node array at all. If you have the edge facts given in the above form, you will have to use findall/3 to make the list of edges: findall(e(From,To,EdgeId), edge(EdgeID,From,To), EdgeList), make_graph(MaxNodeNum, EdgeList, Graph), -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipseReceived on Mon May 14 14:45:44 2001
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:08 PM GMT GMT