Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

graph::easy::layout::path(3pm) [debian man page]

Graph::Easy::Layout::Path(3pm)				User Contributed Perl Documentation			    Graph::Easy::Layout::Path(3pm)

NAME
Graph::Easy::Layout::Path - Path management for Manhattan-style grids SYNOPSIS
use Graph::Easy; my $graph = Graph::Easy->new(); my $bonn = Graph::Easy::Node->new( name => 'Bonn', ); my $berlin = Graph::Easy::Node->new( name => 'Berlin', ); $graph->add_edge ($bonn, $berlin); $graph->layout(); print $graph->as_ascii( ); # prints: # +------+ +--------+ # | Bonn | --> | Berlin | # +------+ +--------+ DESCRIPTION
"Graph::Easy::Layout::Scout" contains just the actual path-managing code for Graph::Easy, e.g. to create/destroy/maintain paths, node placement etc. EXPORT
Exports nothing. SEE ALSO
Graph::Easy. METHODS into Graph::Easy This module injects the following methods into "Graph::Easy": _path_is_clear() $graph->_path_is_clear($path); For all points (x,y pairs) in the path, check that the cell is still free. $path points to a list x,y,type pairs as in "[ [x,y,type], [x,y,type], ...]". _create_cell() my $cell = $graph->($edge,$x,$y,$type); Create a cell at "$x,$y" coordinates with type $type for the specified edge. _path_is_clear() $graph->_path_is_clear(); For all points (x,y pairs) in the path, check that the cell is still free. $path points to a list of "[ x,y,type, x,y,type, ...]". Returns true when the path is clear, false otherwise. _trace_path() my $path = my $graph->_trace_path($src,$dst,$edge); Find a free way from source node/group to destination node/group for the specified edge. Both source and destination need to be placed beforehand. METHODS in Graph::Easy::Node This module injects the following methods into "Graph::Easy::Node": _near_places() my $node->_near_places(); Take a node and return a list of possible placements around it and prune out already occupied cells. $d is the distance from the node border and defaults to two (for placements). Set it to one for adjacent cells. _shuffle_dir() my $dirs = $node->_shuffle_dir( [ 0,1,2,3 ], $dir); Take a ref to an array with four entries and shuffle them around according to $dir. _shift() my $dir = $node->_shift($degrees); Return a the "flow()" direction shifted by X degrees to $dir. AUTHOR
Copyright (C) 2004 - 2007 by Tels <http://bloodgate.com>. See the LICENSE file for information. perl v5.14.2 2011-12-23 Graph::Easy::Layout::Path(3pm)

Check Out this Related Man Page

Graph::Easy::Parser(3pm)				User Contributed Perl Documentation				  Graph::Easy::Parser(3pm)

NAME
Graph::Easy::Parser - Parse Graph::Easy from textual description SYNOPSIS
# creating a graph from a textual description use Graph::Easy::Parser; my $parser = Graph::Easy::Parser->new(); my $graph = $parser->from_text( '[ Bonn ] => [ Berlin ]'. '[ Berlin ] => [ Rostock ]'. ); print $graph->as_ascii(); print $parser->from_file('mygraph.txt')->as_ascii(); # Also works automatically on graphviz code: print Graph::Easy::Parser->from_file('mygraph.dot')->as_ascii(); DESCRIPTION
"Graph::Easy::Parser" lets you parse simple textual descriptions of graphs, and constructs a "Graph::Easy" object from them. The resulting object can than be used to layout and output the graph. Input The input consists of text describing the graph, encoded in UTF-8. Example: [ Bonn ] --> [ Berlin ] [ Frankfurt ] <=> [ Dresden ] [ Bonn ] --> [ Frankfurt ] [ Bonn ] = > [ Frankfurt ] Graphviz In addition there is a bit of magic that detects graphviz code, so input of the following form will also work: digraph Graph1 { "Bonn" -> "Berlin" } Note that the magic detection only works for named graphs or graph with "digraph" at their start, so the following will not be detected as graphviz code because it looks exactly like valid Graph::Easy code at the start: graph { "Bonn" -> "Berlin" } See Graph::Easy::Parser::Graphviz for more information about parsing graphs in the DOT language. VCG In addition there is a bit of magic that detects VCG code, so input of the following form will also work: graph: { node: { title: Bonn; } node: { title: Berlin; } edge: { sourcename: Bonn; targetname: Berlin; } } See Graph::Easy::Parser::VCG for more information about parsing graphs in the VCG language. Input Syntax This is a very brief description of the syntax for the Graph::Easy language, for a full specification, please see Graph::Easy::Manual. nodes Nodes are rendered (or "quoted", if you wish) with enclosing square brackets: [ Single node ] [ Node A ] --> [ Node B ] Anonymous nodes do not have a name and cannot be refered to again: [ ] -> [ Bonn ] -> [ ] This creates three nodes, two of them anonymous. edges The edges between the nodes can have the following styles: -> solid => double .> dotted ~> wave - > dashed .-> dot-dash ..-> dot-dot-dash = > double-dash There are also the styles "bold", "wide" and "broad". Unlike the others, these can only be set via the (optional) edge attributes: [ AB ] --> { style: bold; } [ ABC ] You can repeat each of the style-patterns as much as you like: ---> ==> => ~~~~~> ..-..-..-> Note that in patterns longer than one character, the entire pattern must be repeated e.g. all characters of the pattern must be present. Thus: ..-..-..-> # valid dot-dot-dash ..-..-..> # invalid! .-.-.-> # valid dot-dash .-.-> # invalid! In additon to the styles, the following two directions are possible: -- edge without arrow heads --> arrow at target node (end point) <--> arrow on both the source and target node (end and start point) Of course you can combine all directions with all styles. However, note that edges without arrows cannot use the shortcuts for styles: --- # valid .-.- # valid .- # invalid! - # invalid! ~ # invalid! Just remember to use at least two repititions of the full pattern for arrow-less edges. You can also give edges a label, either by inlining it into the style, or by setting it via the attributes: [ AB ] --> { style: bold; label: foo; } [ ABC ] -- foo --> ... baz ...> -- solid --> == double ==> .. dotted ..> ~~ wave ~~> - dashed - > = double-dash = > .- dot-dash .-> ..- dot-dot-dash ..-> Note that the two patterns on the left and right of the label must be the same, and that there is a space between the left pattern and the label, as well as the label and the right pattern. You may use inline label only with edges that have an arrow. Thus: <-- label --> # valid -- label --> # valid -- label -- # invalid! To use a label with an edge without arrow heads, use the attributes: [ AB ] -- { label: edgelabel; } [ CD ] groups Round brackets are used to group nodes together: ( Cities: [ Bonn ] -> [ Berlin ] ) Anonymous groups do not have a name and cannot be refered to again: ( [ Bonn ] ) -> [ Berlin ] This creates an anonymous group with the node "Bonn" in it, and links it to the node "Berlin". Please see Graph::Easy::Manual for a full description of the syntax rules. Output The output will be a Graph::Easy object (unless overrriden with "use_class()"), see the documentation for Graph::Easy what you can do with it. EXAMPLES
See Graph::Easy for an extensive list of examples. METHODS
"Graph::Easy::Parser" supports the following methods: new() use Graph::Easy::Parser; my $parser = Graph::Easy::Parser->new(); Creates a new parser object. The valid parameters are: debug fatal_errors The first will enable debug output to STDERR: my $parser = Graph::Easy::Parser->new( debug => 1 ); $parser->from_text('[A] -> [ B ]'); Setting "fatal_errors" to 0 will make parsing errors not die, but just set an error string, which can be retrieved with error(). my $parser = Graph::Easy::Parser->new( fatal_errors => 0 ); $parser->from_text(' foo ' ); print $parser->error(); See also catch_messages() for how to catch errors and warnings. reset() $parser->reset(); Reset the status of the parser, clear errors etc. Automatically called when you call any of the "from_XXX()" methods below. use_class() $parser->use_class('node', 'Graph::Easy::MyNode'); Override the class to be used to constructs objects while parsing. The first parameter can be one of the following: node edge graph group The second parameter should be a class that is a subclass of the appropriate base class: package Graph::Easy::MyNode; use base qw/Graph::Easy::Node/; # override here methods for your node class ###################################################### # when overriding nodes, we also need ::Anon package Graph::Easy::MyNode::Anon; use base qw/Graph::Easy::MyNode/; use base qw/Graph::Easy::Node::Anon/; ###################################################### # and :::Empty package Graph::Easy::MyNode::Empty; use base qw/Graph::Easy::MyNode/; ###################################################### package main; use Graph::Easy::Parser; use Graph::Easy; use Graph::Easy::MyNode; use Graph::Easy::MyNode::Anon; use Graph::Easy::MyNode::Empty; my $parser = Graph::Easy::Parser; $parser->use_class('node', 'Graph::Easy::MyNode'); my $graph = $parser->from_text(...); The object $graph will now contain nodes that are of your custom class instead of plain "Graph::Easy::Node". When overriding nodes, you also should provide subclasses for "Graph::Easy::Node::Anon" and "Graph::Easy::Node::Empty", and make these subclasses of your custom node class as shown above. For edges, groups and graphs, you need just one subclass. from_text() my $graph = $parser->from_text( $text ); Create a Graph::Easy object from the textual description in $text. Returns undef for error, you can find out what the error was with error(). This method will reset any previous error, and thus the $parser object can be re-used to parse different texts by just calling "from_text()" multiple times. from_file() my $graph = $parser->from_file( $filename ); my $graph = Graph::Easy::Parser->from_file( $filename ); Creates a Graph::Easy object from the textual description in the file $filename. The second calling style will create a temporary "Graph::Easy::Parser" object, parse the file and return the resulting "Graph::Easy" object. Returns undef for error, you can find out what the error was with error() when using the first calling style. error() my $error = $parser->error(); Returns the last error, or the empty string if no error occured. If you want to catch warnings from the parser, enable catching of warnings or errors: $parser->catch_messages(1); # Or individually: # $parser->catch_warnings(1); # $parser->catch_errors(1); # something which warns or throws an error: ... if ($parser->error()) { my @errors = $parser->errors(); } if ($parser->warning()) { my @warnings = $parser->warnings(); } See Graph::Easy::Base for more details on error/warning message capture. parse_error() $parser->parse_error( $msg_nr, @params); Sets an error message from a message number and replaces embedded templates like "##param1##" with the passed parameters. _parse_attributes() my $attributes = $parser->_parse_attributes( $txt, $class ); my ($att, $multiples) = $parser->_parse_attributes( $txt, $class ); Internal usage only. Takes a text like this: attribute: value; attribute2 : value2; and returns a hash with the attributes. In list context, also returns the max count of multiple attributes, e.g. 3 when it encounters something like "red|green|blue". When EXPORT
Exports nothing. SEE ALSO
Graph::Easy. Graph::Easy::Parser::Graphviz and Graph::Easy::Parser::VCG. AUTHOR
Copyright (C) 2004 - 2007 by Tels <http://bloodgate.com> See the LICENSE file for information. perl v5.14.2 2011-12-23 Graph::Easy::Parser(3pm)
Man Page