Re: library(ugraphs)

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 02/13/2014 10:57 AM, Nicos Angelopoulos wrote:
>
>
> Dear all,
>
> 1.
>	library(ugraphs)  seems to have lost documentation for a number of its predicates-
>	http://www.swi-prolog.org/pldoc/doc/swi/library/ugraphs.pl
>	probably due to a very recent change as my local spuds server had full documentation
>	until the last update from pl-devel

This is a common issue with libraries that are partially documented in
the source, but for which the `official' documentation is still in
LaTeX. The complete docs are in
http://www.swi-prolog.org/pldoc/man?section=ugraphs. The long term
solution is to move the docs to the source and generate the LaTeX from
there as is done for quite a few libraries, notably the ones under more
active development.

If anyone likes to help, submit patches that move the documentation from
the LaTeX source into the library.

> 2.
>	i am not sure if this is of general enough interest to be included in the library,
>	but i recently coded a sub_graphs/2 predicate
>	this includes a use case for the ord_select/3 predicate discussed previously

Richard often has good remarks about such issues ...

	Cheers --- Jan

>
>
> Regards,
>
> Nicos Angelopoulos
> ---
> http://stoics.org.uk/~nicos/
>
>
> :- requires(ord_select/3).
>
> %% sub_graphs(+Graph, -Subs).
> %
> % Subs is all disconnected subgraphs in Graph
> %
> % ==
> % sub_graphs([1-[2,3],2-[3],3-[4],4-[],5-[6,7],6-[],7-[6]], Subs).
> %
> % Subs = [[1-[2, 3], 2-[3], 3-[4], 4-[]], [5-[6, 7], 6-[], 7-[6]]].
> % ==
> %
> % @author nicos angelopoulos
> % @version 0.1  2014/02/12
> %
> sub_graphs([], []).
> sub_graphs(Graph, [Removed|TSubs]) :-
>	\+ var(Graph),                            % can be moved to an outer wrapper, or removed
>	Graph = [Vertex-_|_],
>	reachable(Vertex, Graph, Vertices),
>	select_vertex_entries(Graph, Vertices, Removed, Reduced),
>	sub_graphs(Reduced, TSubs).
>
> %% del_vertex_entries(+Graph, +Vertices, -Removed, -Reduced).
> %
> %  Delete the entries for a set of Vertices from Graph.
> %  This differs from del_vertices/3, in that it does not remove edges and also
> %  returns what was removed.  The main use case for this predicate,
> %  is for when we are removing whole isolated sub graphs.
> %  It probably best, it should be kept away from library interfaces.
> %  This version fails if one of the Vertices is not in Graph.
> %
> %  @author nicos angelopoulos
> %  @version 0.1  2014/02/12
> %
> select_vertex_entries([], [], [], []).                        % test 2nd arg if you want to throw error.
> select_vertex_entries([V-Edged|T], Vertices, Removed, Reduced) :-
>	ord_select(Vertices, V, RemVertices),
>	!,
>	Removed = [V-Edged|TRemoved],
>	select_vertex_entries(T, RemVertices, TRemoved, Reduced).
> select_vertex_entries([V-Edged|T], Vertices, Removed, [V-Edged|TReduced]) :-
>	select_vertex_entries(T, Vertices, Removed, TReduced).
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.