% Draw a random walk trace and find short paths in it.

function path_example(n)

%tic
   list=[];
   while isempty(list)
      [dir_edges,out_list,verts]=make_trace(n)
      [tree,dist]=find_span_tree2(dir_edges,out_list,1);
      e_dist=sqrt((verts(:,1)-verts(1,1)).^2+...
           (verts(:,2)-verts(1,2)).^2);
      d=max(e_dist);
      list=find(e_dist>.8*d);
      [m,p]=min(dist(list));
   end % while 
      figure; axis equal; axis off; hold on;
      plot_edge_list(dir_edges,verts)
     scatter(verts(1,1),verts(1,2),'r','filled','MarkerEdgeColor','k');

      figure; axis equal; axis off; hold on;
      plot_spanning_tree(tree,verts);
      figure; axis equal; axis off; hold on;
      plot_edge_list(dir_edges,verts);
      plot_tree_path(tree,verts,list(p));
%toc
return 
