.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "TM::Graph 3pm" .TH TM::Graph 3pm "2019-09-07" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" TM::Graph \- Topic Maps, trait for graph\-like operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use TM::Materialized::AsTMa; \& my $tm = new TM::Materialized::AsTMa (file => \*(Aqold_testament.atm\*(Aq); \& $tm\->sync_in; \& Class::Trait\->apply ( $tm => \*(AqTM::Graph\*(Aq ); \& \& # find groups of topics connected \& print Dumper $tm\->clusters; \& \& \& # use association types to compute a hull \& print "friends of Mr. Cairo: ". \& Dumper [ \& $tm\->frontier ([ $tm_>tid (\*(Aqmr\-cairo\*(Aq) ], [ [ $tm\->tids (\*(Aqfoaf\*(Aq) ] ]) \& ]; \& \& # see whether there is a link (direct \& print "I always knew it" \& if $tm\->is_path ( [ \*(Aqgw\-bush\*(Aq ], # there could be more \& (bless [ [ \*(Aqfoaf\*(Aq ] ], \*(Aq*\*(Aq), \& \*(Aqosama\-bin\-laden\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Obviously a topic map is also a graph, the topics being the nodes, and the associations forming the edges, albeit these connections connect not always only two nodes, but, ok, you should know TMs by now. .PP This package provides some functions which focus more on the graph-like nature of Topic Maps. .SH "INTERFACE" .IX Header "INTERFACE" .SS "Methods" .IX Subsection "Methods" This trait provides the following methods: .IP "\fBclusters\fR" 4 .IX Item "clusters" \&\fI\f(CI$hashref\fI\fR = clusters (\fI\f(CI$tm\fI\fR) .Sp computes the \fIislands\fR of topics. It figures out which topics are connected via associations and \- in case they are \- will collate them into clusters. The result is a hash reference to a hash containing list references of topic ids organized in a cluster. .Sp In default mode, this function only regards topics to be in the same cluster if topics \fBplay\fR roles in one and the same maplet. The role topics themselves or the type or the scope are ignored. .Sp You can change this behaviour by passing in options like .Sp .Vb 1 \& use_scope => 1 \& \& use_roles => 1 \& \& use_type => 1 .Ve .Sp Obviously, with \f(CW\*(C`use_scope => 1\*(C'\fR you will let a lot of topics collapse into one cluster as most maplets usually are in the unconstrained scope. .Sp \&\fB\s-1NOTE\s0\fR: This is yet a somewhat expensive operation. .IP "\fBfrontier\fR" 4 .IX Item "frontier" \&\fI\f(CI@hull\fI\fR = \fI\f(CI$tm\fI\fR\->frontier (\fI\e@start_lids\fR, \fI\f(CI$path_spec\fI\fR) .Sp This method computes a \fIqualified hull\fR, i.e. a list of all topics which are reachable from \&\fI\f(CI@start_lids\fI\fR via a path specified by \fI\f(CI$path_spec\fI\fR. The path specification is a (recursive) data structure, describing sequences, alternatives and repetition (the \f(CW\*(C`*\*(C'\fR operator), all encoded as lists of lists. The topics in that path specification are interpreted as assertion types. .Sp Example (reformatting for better reading): .Sp .Vb 3 \& # a single step: start knows ... \& [ ] # outer level: sequence (there is only one) \& [ \*(Aqknows\*(Aq ] # inner level: alternatives (there is only one) \& \& # two subsequent steps: start knows ... isa ... \& [ ] # outer level: two entries \& [ \*(Aqknows\*(Aq ], [ \*(Aqisa\*(Aq ] # inner level, one entry each \& \& # repetition: start knows ... knows ... knows ... ad infinitum \& bless [ ], \*(Aq*\*(Aq # outer level: one entry, but blessed \& [ \*(Aqknows\*(Aq ] # inner level \& \& # alternatives: start knows | hates ... \& [ ] # outer level: one entry \& [ \*(Aqknows\*(Aq, \*(Aqhates\*(Aq ] # inner level: alternatives \& \& # nesting: first follow an \*(Aqeats\*(Aq, then any number of \*(Aqbegets\*(Aq \& [ ] \& [ \*(Aqeats\*(Aq ], [ ] \& bless [ ], \*(Aq*\*(Aq \& [ \*(Aqbegets\*(Aq ] .Ve .Sp \&\fB\s-1NOTE\s0\fR: All tids have to be made map-absolute with \f(CW\*(C`tids\*(C'\fR. .Sp \&\fB\s-1NOTE\s0\fR: Cycles are detected. .Sp \&\fB\s-1NOTE\s0\fR: I am not sure how this performs at rather large graphs, uhm, maps. .IP "\fBis_path\fR" 4 .IX Item "is_path" \&\fI\f(CI$bool\fI\fR = \fI\f(CI$tm\fI\fR\->is_path (\fI\e@start_lids\fR, \fI\f(CI$path_spec\fI\fR, \fI\f(CI$end_lid\fI\fR) .Sp This method returns \f(CW1\fR if there is a path from \fIstart_lids\fR to \fIend_lid\fR via the path specification. See \fBfrontier\fR for that one. .IP "\fBneighborhood\fR" 4 .IX Item "neighborhood" \&\fI\f(CI@neighbors\fI\fR = \fI\f(CI$tm\fI\fR\->neighborhood (\fI\f(CI$MAXDEPTH\fI\fR, \fI\e@start_lids\fR) .Sp This method returns a list of neighbors for the given start LIDs. In that it follows paths with the maximal length given as first parameter. In any case the path with length \f(CW0\fR is returned, which includes any of the starting nodes. .Sp Each neighbor is represented by a hash (reference) with the \f(CW\*(C`path\*(C'\fR and the \f(CW\*(C`end\*(C'\fR \s-1LID.\s0 The \fIpath\fR is a list (reference) holding the LIDs of the association types visited along the path. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1TM\s0 .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 200[78] by Robert Barta, .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.