Template:EdgesTo

From AtlasWiki
Jump to: navigation, search

Format

To obtain a list of more generic "permitted" edge relationships, use

{{EdgesTo|node kind|permitted}}

To obtain a list of specified edge relationships, use

{{EdgesTo|node kind|specified}}

Description

Returns a list of all permitted or specified edges to the specified Node.

If there is just one edge to from just one other node, the resulting list will look like:

[edge]<EDGE_PROP>[description]<EDGE_PROP>[origin node]<VAL>[multiplicity]

If the same edge kind can have multiple origins, the multiple origin/multiplicity pairs are separated by <MANY>, for example, given three possible origins, the result would be:

[edge]<EDGE_PROP>[description]<EDGE_PROP>[origin 1]<VAL>[multiplicity 1]<MANY>[origin 2]<VAL>[multiplicity 2]<MANY>[origin 3]<VAL>[multiplicity 3]

If there are multiple edge types, those will be separated by <EDGE_SEP>, e.g. two edge types with two possible origins for the first, and one for the second would look be:

[edge]<EDGE_PROP>[description]<EDGE_PROP>[origin 1]<VAL>[multiplicity 1]<MANY>[origin 2]<VAL>[multiplicity 2]<EDGE_SEP>[edge 2]<EDGE_PROP>[description]<EDGE_PROP>[origin of edge 2]<VAL>[multiplicity of edge 2]

Parsing

Ultimately that means the return value can be parsed as follows:

Splitting on <EDGE_SEP> will split into strings, each representing all incoming connections for a particular edge type.

Splitting one of those edge strings on <EDGE_PROP> will split the string into three pieces: the edge kind, the edge description, and a list of origin/multiplicity pairs.

The list of origin/multiplicity pairs must be split on <MANY> to separate out the individual pairs.

Then each pair can then be split on <VAL> to split it into the origin node kind and the multiplicity of incoming edges of the specified type from the specified node kind.

Notes

It is sometimes important to realize you can use #arrayslice from the Arrays extension to obtain an array of all origin/multiplicity pairs except the first. This allows one to format the first table row individually, then use #arrayprint with the sliced remaining origin/multiplicity pairs. Without slicing the array, it would be necessary to print all rows identically, meaning it would be necessary to repeat the description and edge name in every row, instead of setting up an appropriate row-span for their cells in the table.