Broadcasting

Description

This example tries to solve the problem of sending a signal every node in a tree, and returning the number of children of every node.

Model

The corresponding P-Lingua file is the following:

/* Broadcast with acknowledgement: counting the number of children of a DAG*/
/* At the end of the execution each node should contain a number of bs equal
to the number of children of the respective node */

@model<simple_kernel_psystems>
def main()
{
        @mu = [[a,b]'1 [a]'2 [a]'3 [a]'4 [a]'5 [a]'6 [a]'7 [a]'8]'0;

        [a,b]'1 --> [b]'2 [b]'3 [b]'4;
        [d --> b]'1;

        [a,b]'2 --> [d]'1;

        [a,b]'3 --> [c]'3 [b]'5 [b]'6;
        [d]'3 --> [b]'3 [d]'1;
        [c]'3 --> [d]'1;

        [a,b]'4 --> [c]'4 [b]'7;
        [d]'4 --> [b]'4 [d]'1;
        [c]'4 --> [d]'1;

        [a,b]'5 --> [d]'3;

        [a,b]'6 --> [c]'6 [b]'8;
        [d]'6 --> [b]'6 [d]'3;
        [c]'6 --> [d]'3;

        [a,b]'7 --> [d]'4;

        [a,b]'8 --> [d]'6;
}

Files

A first run

Final results

../../_images/BroadcastingGraph.png