Ticket #35: lgf-page.patch
File lgf-page.patch, 16.9 KB (added by , 17 years ago) |
---|
-
new file doc/lgf.dox
# HG changeset patch # User Alpar Juttner <alpar@cs.elte.hu> # Date 1210833006 -3600 # Node ID 8965fe652c0c4df1cc32aebd264497f6c8c86f35 # Parent a765b4ecbcdbd5e8ac0fc55beecf585ebb481b15 LGF doc goes into a separate page + several fixes in lgf doc diff --git a/doc/lgf.dox b/doc/lgf.dox new file mode 100644
- + 1 /* -*- C++ -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 4 * 5 * Copyright (C) 2003-2008 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 * 9 * Permission to use, modify and distribute this software is granted 10 * provided that this copyright notice appears in all copies. For 11 * precise terms see the accompanying LICENSE file. 12 * 13 * This software is provided "AS IS" with no warranty of any kind, 14 * express or implied, and with no claim as to its suitability for any 15 * purpose. 16 * 17 */ 18 19 namespace lemon { 20 /*! 21 22 23 24 \page lgf-format Lemon Graph Format (LGF) 25 26 The \e LGF is a <em>column oriented</em> 27 file format for storing graphs and associated data like 28 node and edge maps. 29 30 Each line with \c '#' first non-whitespace 31 character is considered as a comment line. 32 33 Otherwise the file consists of sections starting with 34 a header line. The header lines starts with an \c '@' character followed by the 35 type of section. The standard section types are \c \@nodes, \c 36 \@arcs and \c \@edges 37 and \@attributes. Each header line may also have an optional 38 \e name, which can be use to distinguish the sections of the same 39 type. 40 41 The standard sections are column oriented, each line consists of 42 <em>token</em>s separated by whitespaces. A token can be \e plain or 43 \e quoted. A plain token is just a sequence of non-whitespace characters, 44 while a quoted token is a 45 character sequence surrounded by double quotes, and it can also 46 contain whitespaces and escape sequences. 47 48 The \c \@nodes section describes a set of nodes and associated 49 maps. The first is a header line, it columns are the names of the 50 maps appearing in the following lines. 51 One of the maps must be called \c 52 "label", which plays special role in the file. 53 The following 54 non-empty lines until the next section describes nodes of the 55 graph. Each line contains the values of the node maps 56 associated to the current node. 57 58 \code 59 @nodes 60 label coordinates size title 61 1 (10,20) 10 "First node" 62 2 (80,80) 8 "Second node" 63 3 (40,10) 10 "Third node" 64 \endcode 65 66 The \c \@arcs section is very similar to the \c \@nodes section, 67 it again starts with a header line describing the names of the arc, 68 but the \c "label" map is not obligatory here. The following lines 69 describe the arcs. The first two tokens of each line are 70 the source and the target node of the arc, respectively, then come the map 71 values. The source and target tokens must be node labels. 72 73 \code 74 @arcs 75 capacity 76 1 2 16 77 1 3 12 78 2 3 18 79 \endcode 80 81 The \c \@edges is just a synonym of \c \@arcs. 82 83 The \c \@attributes section contains key-value pairs, each line 84 consists of two tokens, an attribute name, and then an attribute value. 85 86 \code 87 @attributes 88 source 1 89 target 3 90 caption "LEMON test digraph" 91 \endcode 92 93 */ 94 } 95 96 // LocalWords: whitespace whitespaces -
lemon/lgf_reader.h
diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h
a b 275 275 /// 276 276 /// \brief LGF reader for directed graphs 277 277 /// 278 /// The \e LGF (LEMON graph file) format is the default file format 279 /// of the LEMON library. It is a text based, section oriented 280 /// format, which defines some standard sections for storing graphs 281 /// in text files. Each line with \c '#' first non-whitespace 282 /// character is considered as a comment line. Each section starts with 283 /// a header line, these lines starts with \c '@' character and the 284 /// name of section type. The standard sections are \c \@nodes, \c 285 /// \@arcs and \c \@edges (these two names are completely equivalent) 286 /// and \@attributes. Each header line may also have an optional 287 /// name, which can be use to distinguish the sections of the same 288 /// type. 278 /// This utility reads an \ref lgf-format "LGF" file. 289 279 /// 290 /// The \@nodes section describes a set of nodes and associated 291 /// maps. The first is a header line consisting of the names of the 292 /// maps, each of them is a plain or quoted token. A plain token is 293 /// a sequence of non-whitespace characters, and a quoted token is a 294 /// character sequence surrounded by double quotes, and the sequence 295 /// may contain escape sequences. One of the maps must be called \c 296 /// "label", which plays special role in the file. Each following 297 /// non-empty line until the next section describes a node in the 298 /// graph. These lines contain the values of the node maps 299 /// associated to the current node, each value is also plain or 300 /// quoted token. 301 /// 302 /// The \c \@arcs section is very similar to the \c \@nodes section, 303 /// it starts with a header line consists from the names of the arc 304 /// maps, the \c "label" map is also necessary. The following lines 305 /// contain the description of the arcs. The first two tokens are 306 /// the source and the target node of the edge, then comes the map 307 /// values. The source and target tokens must be node labels. 308 /// 309 /// The \c \@attributes section contains key-value pairs, each line 310 /// starts with an attribute nome, and then an attribute value. Both 311 /// of them are plain or quoted tokens, but the value could be also 312 /// a node or an arc label. 280 /// The reading method does a batch processing. The user creates a 281 /// reader object, then various reading rules can be added to the 282 /// reader, and eventually the reading is executed with the \c run() 283 /// member function. A map reading rule can be added to the reader 284 /// with the \c nodeMap() or \c arcMap() members. An optional 285 /// converter parameter can also be added as a standard functor converting from 286 /// std::string to the value type of the map. If it is set, it will 287 /// determine how the tokens in the file should be is converted to the map's 288 /// value type. If the functor is not set, then a default conversion 289 /// will be used. One map can be read into multiple map objects at the 290 /// same time. The \c attribute(), \c node() and \c arc() functions 291 /// are used to add attribute reading rules. 313 292 /// 314 293 ///\code 315 /// @nodes 316 /// label coordinates size title 317 /// 1 (10,20) 10 "First node" 318 /// 2 (80,80) 8 "Second node" 319 /// 3 (40,10) 10 "Third node" 320 /// @arcs 321 /// capacity 322 /// 1 2 16 323 /// 1 3 12 324 /// 2 3 18 325 /// @attributes 326 /// source 1 327 /// target 3 328 /// caption "LEMON test digraph" 329 ///\endcode 330 /// 331 /// The writing method does a batch processing. The user creates a 332 /// writer object, then several writing rules can be added to the 333 /// writer, and eventually the writing is executed with the \c run() 334 /// member function. A map writing rule can be added to the writer 335 /// with the \c nodeMap() or \c arcMap() members. The optional 336 /// converter parameter can be a standard functor, which converts an 337 /// the value type of the map to std::string, if it is set, it 338 /// determines how the the map's value type is written to the output 339 /// stream. If the functor is not set, then a default conversion 340 /// will be used. The \c attribute(), \c node() and \c arc() functions 341 /// are used to add attribute writing rules. 342 /// 343 ///\code 344 /// DigraphWriter<Digraph>(std::cout, digraph). 294 /// DigraphReader<Digraph>(std::cin, digraph). 345 295 /// nodeMap("coordinates", coord_map). 346 /// nodeMap("size", size).347 /// nodeMap("title", title).348 296 /// arcMap("capacity", cap_map). 349 297 /// node("source", src). 350 298 /// node("target", trg). … … 352 300 /// run(); 353 301 ///\endcode 354 302 /// 355 /// By default the writer uses the first section in the file of the303 /// By default the reader uses the first section in the file of the 356 304 /// proper type. If a section has an optional name, then it can be 357 /// selected to write with the \c nodes(), \c arcs() or \c attributes() 305 /// selected for reading by giving an optional name parameter to 306 /// the \c nodes(), \c arcs() or \c attributes() 358 307 /// functions. 359 308 /// 360 /// The \c useNodes() and \c useArcs() functions are used to specify361 /// that the nodes or arcs should not be constructed (added to the362 /// graph) during the reading, the argument of these functions is a363 /// node map or arc map determining the label map for the items. An364 /// application of these function is themultipass reading, which is365 /// important if two \e \@arcs sections shouldbe read from the366 /// file. In this example the first phase readsthe node set and one367 /// of the arc set , while the second phase willread the second arc368 /// set into an \e ArcSet class (\c SmartArcSet or \c ListArcSet) ,369 /// the previously read label node map should be givento the \c370 /// useNodes() functions. An other multipass application is reading371 /// paths into a node map or an arc map. It is impossiblein372 /// single pass, because the arcs are not constructed when the node309 /// The \c useNodes() and \c useArcs() functions are used to tell the reader 310 /// that the nodes or arcs should not be constructed (added to the 311 /// graph) during the reading, but instead the label map of the items 312 /// are given as a parameter of these functions. An 313 /// application of these function is multipass reading, which is 314 /// important if two \e \@arcs sections must be read from the 315 /// file. In this example the first phase would read the node set and one 316 /// of the arc sets, while the second phase would read the second arc 317 /// set into an \e ArcSet class (\c SmartArcSet or \c ListArcSet). 318 /// the previously read label node map should be passed to the \c 319 /// useNodes() functions. Another application of multipass reading when 320 /// paths are given as a node map or an arc map. It is impossible read this in 321 /// a single pass, because the arcs are not constructed when the node 373 322 /// maps are read. 374 323 template <typename _Digraph> 375 324 class DigraphReader { … … 442 391 /// \brief Copy constructor 443 392 /// 444 393 /// The copy constructor transfers all data from the other reader, 445 /// therefore the copied reader will not be us eable more.394 /// therefore the copied reader will not be usable more. 446 395 DigraphReader(DigraphReader& other) 447 396 : _is(other._is), local_is(other.local_is), _digraph(other._digraph), 448 397 _use_nodes(other._use_nodes), _use_arcs(other._use_arcs) { -
lemon/lgf_writer.h
diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h
a b 236 236 /// 237 237 /// \brief LGF writer for directed graphs 238 238 /// 239 /// The \e LGF (LEMON graph file) format is the default file format 240 /// of the LEMON library. It is a text based, section oriented 241 /// format, which defines some standard sections for storing graphs 242 /// in text files. Each line with \c '#' first non-whitespace 243 /// character is considered as a comment line. Each section starts with 244 /// a header line, these lines starts with \c '@' character and the 245 /// name of section type. The standard sections are \c \@nodes, \c 246 /// \@arcs and \c \@edges (these two names are completely equivalent) 247 /// and \@attributes. Each header line may also have an optional 248 /// name, which can be use to distinguish the sections of the same 249 /// type. 239 /// This utility writes an \ref lgf-format "LGF" file. 250 240 /// 251 /// The \@nodes section describes a set of nodes and associated 252 /// maps. The first is a header line consisting of the names of the 253 /// maps, each of them is a plain or quoted token. A plain token is 254 /// a sequence of non-whitespace characters, and a quoted token is a 255 /// character sequence surrounded by double quotes, and the sequence 256 /// may contain escape sequences. One of the maps must be called \c 257 /// "label", which plays special role in the file. Each following 258 /// non-empty line until the next section describes a node in the 259 /// graph. These lines contain the values of the node maps 260 /// associated to the current node, each value is also plain or 261 /// quoted token. 262 /// 263 /// The \c \@arcs section is very similar to the \c \@nodes section, 264 /// it starts with a header line consists from the names of the arc 265 /// maps, the \c "label" map is also necessary. The following lines 266 /// contain the description of the arcs. The first two tokens are 267 /// the source and the target node of the edge, then comes the map 268 /// values. The source and target tokens must be node labels. 269 /// 270 /// The \c \@attributes section contains key-value pairs, each line 271 /// starts with an attribute nome, and then an attribute value. Both 272 /// of them are plain or quoted tokens, but the value could be also 273 /// a node or an arc label. 241 /// The writing method does a batch processing. The user creates a 242 /// writer object, then various writing rules can be added to the 243 /// writer, and eventually the writing is executed with the \c run() 244 /// member function. A map writing rule can be added to the writer 245 /// with the \c nodeMap() or \c arcMap() members. An optional 246 /// converter parameter can also be added as a standard functor converting from 247 /// the value type of the map to std::string. If it is set, it will 248 /// determine how the map's value type is written to the output 249 /// stream. If the functor is not set, then a default conversion 250 /// will be used. The \c attribute(), \c node() and \c arc() functions 251 /// are used to add attribute writing rules. 274 252 /// 275 253 ///\code 276 /// @nodes 277 /// label coordinates size title 278 /// 1 (10,20) 10 "First node" 279 /// 2 (80,80) 8 "Second node" 280 /// 3 (40,10) 10 "Third node" 281 /// @arcs 282 /// capacity 283 /// 1 2 16 284 /// 1 3 12 285 /// 2 3 18 286 /// @attributes 287 /// source 1 288 /// target 3 289 /// caption "LEMON test digraph" 290 ///\endcode 291 /// 292 /// The reading method does a batch processing. The user creates a 293 /// writer object, then several reading rules can be added to the 294 /// writer, and eventually the reading is executed with the \c run() 295 /// member function. A map reading rule can be added to the writer 296 /// with the \c nodeMap() or \c arcMap() members. The optional 297 /// converter parameter can be a standard functor, which converts an 298 /// std::string to the value type of the map, if it is set, it 299 /// determines how the read string literal is converted to the map's 300 /// value type. If the functor is not set, then a default conversion 301 /// will be used. One map can be read in multiple map objects at the 302 /// same time. The \c attribute(), \c node() and \c arc() functions 303 /// are used to add attribute reading rules. 304 /// 305 ///\code 306 /// DigraphWriter<Digraph>(std::cin, digraph). 254 /// DigraphWriter<Digraph>(std::cout, digraph). 307 255 /// nodeMap("coordinates", coord_map). 256 /// nodeMap("size", size). 257 /// nodeMap("title", title). 308 258 /// arcMap("capacity", cap_map). 309 259 /// node("source", src). 310 260 /// node("target", trg). … … 312 262 /// run(); 313 263 ///\endcode 314 264 /// 315 /// By default the writer does not write additional captions to the 316 /// section, but they can added with the \c nodes(), \c arcs() or \c 265 /// 266 /// By default, the writer does not write additional captions to the 267 /// sections, but they can be give as an optional parameter of 268 /// the \c nodes(), \c arcs() or \c 317 269 /// attributes() functions. 318 270 /// 319 271 /// The \c skipNodes() and \c skipArcs() functions forbid the 320 /// writing of the sections. If two arc sections should writeto the321 /// output, it can be made in two passes, the first pass writes the272 /// writing of the sections. If two arc sections should be written to the 273 /// output, it can be done in two passes, the first pass writes the 322 274 /// node section and the first arc section, then the second pass 323 275 /// skips the node section and writes just the arc section to the 324 276 /// stream. The output stream can be retrieved with the \c ostream() 325 /// function, hence the second pass can append the output of the277 /// function, hence the second pass can append its output to the output of the 326 278 /// first pass. 327 279 template <typename _Digraph> 328 280 class DigraphWriter { … … 392 344 /// \brief Copy constructor 393 345 /// 394 346 /// The copy constructor transfers all data from the other writer, 395 /// therefore the copied writer will not be us eable more.347 /// therefore the copied writer will not be usable more. 396 348 DigraphWriter(DigraphWriter& other) 397 349 : _os(other._os), local_os(other.local_os), _digraph(other._digraph), 398 350 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {