This is some functions for Pari/GP making calculations on labelled oriented trees and forests (graph theory trees) as "vpar" vector of parent vertex numbers. Functions include

Vertices are numbered 1 to n. A tree is a vector "vpar" where vpar[v] is parent of v, or 0 if no parent. Such a representation is oriented in that there is a distinguished root (or roots for a forest) and labelled in that each vertex has a particular number. There are no other attributes etc.

       ^ ^          tree, root=3
      /   \
     1     5        vpar=[3,1,0,1,3]
    ^ ^
   /   \
  2     4

The main use is to calculate or verify properties of specific trees of interest. Various functions like diameter are the same for any root or labelling so effectively act as on a "free" tree and the vertex numbers just for tree creation. Most functions are linear in the number of vertices so can be used on large trees.

Connections to Pari/GP specifics include polynomials for roots (spectra), matrices for some linear algebra, Set()s for independent sets, permutations in relabelling and automorphisms, and then general compactness of GP for experimenting etc. is free software (free as in freedom), published under the terms of the GNU General Public License (v3 or higher). Download version 18 here, (729k, and sig), or compressed (194k)
vpar-18.tar.gz (1027k, and sig)

Just is enough to run. Comments at the start give an introduction and overview, then each function has an addhelp(). The tar file includes some example scripts, self-tests, and work-in-progress extras. The extras mostly work but may change wildly. The sig files are Gnu PG ascii armoured signatures generated from my key.

The examples include bits of

See also gentreeg in the Nauty tools which can generate free trees in vertex parent form, and other forms, and can be used command line or C.

See my Graph-Maker-Other for other graph (and tree) creation in Perl.

This page Copyright 2017, 2018, 2019, 2020 Kevin Ryde, except for the GPLv3 logo which is Copyright Free Software Foundation and used here in accordance with its terms.

(Back to the sitemap, or the Pari/GP section there).