Section 5.1 described the three representations supported by MatrixPro text files. All examples in this appendix can be found in the $MATRIX/code/examples/ directory.
#matrix graph 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
#matrix graph adjacency-list A:B C D B:C C:E D:E E:B F:G G:H H:F
#matrix array A B C D E F
There is also an extended text file representation which makes it possible for one file to contain an arbitrary number of structures. It also enables keys in the structures to contain special characters like spaces. With this representation, structures can be nested. For example:
#matrix structures //header of the file test#1 //name of the first main structure #matrix graph adjacency-list //header of the structure a:test#1_1 c //keys in adjacency-list format test#1_1:e //test#1_1 is an inner structure c:d e:test#1_2 #EOS //end of structure -character test#1_1 //description of the inner structure #matrix array a b c #EOS test#1_2 //another inner structure #matrix graph adjacency-list key1:key2 key3 key4 key2:test#1_2_1 key4:key6 key7 #EOS test#1_2_1 #matrix array d e f #EOS test#2 //another main structure #matrix array //header of the structure asdf //keys in array format test#2_1 qwerty #EOS test#2_1 //inner structure #matrix array aa bb cc dd #EOS
The names of the main structures must end with a number (for example, structure#1) to distinguish them inner structures. Names of the inner structures should be chosen so that it is easy to recognize their parent structures (for example, structure#1_1). The description of the structure comes after its name. This can be either in adjacency-list or in array representation. The end of a structure is marked by #EOS.
If the keys contain special characters like spaces, _ or #, they must be preceded by a single quote ' (for example, inner' structure, a'_b, '#matrix). The quote character is removed when the keys are used. If many nodes have the same key in graph, these duplicates can be marked by adding a number at the end (for example, key, key_2).
Indentation can be freely used, for example, to set off inner structures from outer structures. Comments start with string //. Space is also removed from the end of each line.
Some information about the visualization of each structure (representation, rotated, minimized, and name) can be saved into a file. For example:
test#1 //name of the structure in ASCII file #representation layered graph #rotated true #minimized false #name Binary Tree //title of the opened structure #matrix graph adjacency-list //header of the structureThe structure created from a text file can be visualized as either a tree or a graph. However, if a structure is saved to a text file, its functionality is not saved, only its structure. Additional information can be saved about some structures. Currently, this works only for binary trees: if a BST is saved to a text file and then reopened, it is opended as a binary tree not as a general structure. For example:
#matrix structures structure#1 #name Binary Tree #matrix autopolymorph matrix.structures.FDT.probe.BinTree //header Ns1:5QH BpW 5QH:null s8J s8J:null GFc GFc:null null BpW:Ns1_2 Ddv Ns1_2:null null Ddv:null null #EOSThis header contains information about what structure should be loaded, in this case, a binary tree. Structures that are implemented as binary trees (AVL Trees, Red-Black Trees, Splay Trees, etc.) can be saved and loaded as a binary trees.
The first key in the structure description (Ns1 in this example) becomes the root node of the binary tree. The string null is recognized while loading the ASCII file and will be replaced with an empty node in the structure. This is only necessary when the left child of a node is empty and the right child contains some key.