74
74
check_type(Ts, protected, L);
75
75
check_type([private | Ts], _, L) ->
76
76
check_type(Ts, private, L);
77
check_type([public | Ts], _, L) ->
78
check_type(Ts, public, L);
79
77
check_type([T | _], _, _) ->
80
78
{error, {unknown_type, T}};
81
79
check_type([], A, L) -> {A,L}.
252
250
do_del_vertices([V | Vs], G) ->
253
251
do_del_vertex(V, G),
254
252
do_del_vertices(Vs, G);
255
do_del_vertices([], _) -> true.
253
do_del_vertices([], #graph{}) -> true.
258
255
do_del_vertex(V, G) ->
259
256
do_del_nedges(ets:lookup(G#graph.ntab, {in,V}), G),
260
257
do_del_nedges(ets:lookup(G#graph.ntab, {out,V}), G),
261
258
ets:delete(G#graph.vtab, V).
264
260
do_del_nedges([{_,E} | Ns], G) ->
265
261
case ets:lookup(G#graph.etab, E) of
378
374
get_path(G, V1, V2) ->
379
one_path(out_neighbours(G, V1), V2, [], [V1], [V1], {1,infinity}, G, 1).
375
one_path(out_neighbours(G, V1), V2, [], [V1], [V1], 1, G, 1).
382
%% prune_path (evaluate conditions on path)
383
%% long : if path is too long
384
%% short : if path is to short
378
%% prune_short_path (evaluate conditions on path)
379
%% short : if path is too short
385
380
%% ok : if path is ok
387
prune_path(Counter, {Min,_Max}) when Counter < Min ->
382
prune_short_path(Counter, Min) when Counter < Min ->
389
prune_path(_Counter, {_Min,Max}) when Max =:= infinity ->
391
prune_path(Counter, {_Min,Max}) when Counter > Max ->
393
prune_path(_Counter, {_Min, _Max}) ->
384
prune_short_path(_Counter, _Min) ->
396
387
one_path([W|Ws], W, Cont, Xs, Ps, Prune, G, Counter) ->
397
case prune_path(Counter, Prune) of
398
long -> one_path([], W, Cont, Xs, Ps, Prune, G, Counter);
388
case prune_short_path(Counter, Prune) of
399
389
short -> one_path(Ws, W, Cont, Xs, Ps, Prune, G, Counter);
400
390
ok -> lists:reverse([W|Ps])
402
392
one_path([V|Vs], W, Cont, Xs, Ps, Prune, G, Counter) ->
403
case prune_path(Counter, Prune) of
404
long -> one_path([], W, Cont, Xs, Ps, Prune, G, Counter);
406
case lists:member(V, Xs) of
407
true -> one_path(Vs, W, Cont, Xs, Ps, Prune, G, Counter);
408
false -> one_path(out_neighbours(G, V), W,
409
[{Vs,Ps} | Cont], [V|Xs], [V|Ps],
393
case lists:member(V, Xs) of
394
true -> one_path(Vs, W, Cont, Xs, Ps, Prune, G, Counter);
395
false -> one_path(out_neighbours(G, V), W,
396
[{Vs,Ps} | Cont], [V|Xs], [V|Ps],
413
399
one_path([], W, [{Vs,Ps}|Cont], Xs, _, Prune, G, Counter) ->
414
400
one_path(Vs, W, Cont, Xs, Ps, Prune, G, Counter-1);