1 /** This file is part of Shapes.
3 ** Shapes is free software: you can redistribute it and/or modify
4 ** it under the terms of the GNU General Public License as published by
5 ** the Free Software Foundation, either version 3 of the License, or
8 ** Shapes is distributed in the hope that it will be useful,
9 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ** GNU General Public License for more details.
13 ** You should have received a copy of the GNU General Public License
14 ** along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 ** Copyright 2014 Henrik Tidefelt
19 ##needs ..Shapes..Data / seq-support
22 ##lookin ..Shapes..Data
24 /** Helper function for converting a sequence to a string, with elements separated by spaces.
26 seq_sep_string: \ seq → [seq_string [separate ` ´ seq]]
28 /** Set up a graph to work with. **/
29 g: [graph undirected:true
30 nodes: [list 'a 'b 'c 'd]
31 edges: [list (> 'a 'b <) (> 'a 'c <) (> 'b 'c <) (> 'd 'b <) (> 'd 'a <)]
34 /** Define a walk directly in terms of edges of the graph. Usually, the edges are
35 ** the result of some kind of search of traversal, but this time we just pick
48 /** Examine the walk. **/
49 IO..•stdout << `Length of walk: ´ << w.edge_count << "{n}
50 IO..•stdout << `Simple?: ´ << w.simple? << "{n}
51 IO..•stdout << `Node cover?: ´ << w.node_cover? << "{n}
52 IO..•stdout << `Edge cover?: ´ << w.edge_cover? << "{n}
53 IO..•stdout << `Open or closed: ´ << [if w.open? `open´ `closed´] << "{n}
54 IO..•stdout << `Edges in the walk: ´ << [seq_sep_string w.edges] << "{n}
56 /** Visit all nodes along the walk. **/
57 IO..•stdout << `Node keys along the walk: ´ << w.start.key
58 ignore [] [w.edges.foldsl
62 •dst << ` ´ << next.key
70 /** Prevent empty output error. **/