| NORSYS SOFTWARE © 2010 | NETICA API | C VERSION 4.18

void DeleteLink_bn ( | int link_index, node_bn* child )

Removes the link going to child from the link_indexth parent node of child.

link_index should be 0 for the first parent, and must be less than the number of links entering child (the parent ordering is given by GetNodeParents_bn).

It is often more useful to be able to delete a link by specifying the 2 nodes it connects. In order to do this use the function DeleteLink defined in the example below, and in NeticaEx.c.

If child has a CPT or function table, it is collapsed as if the removed parent were taking on its first state (state = 0), unless there is a positive finding entered for the parent, in which case it is collapsed with the parent taking on the finding state.

WARNING: When a link is deleted, keep in mind that the numbering of subsequent links changes. For example, to delete all the links entering a node, use the method "DeleteLinksEntering" example below, not: for (pn = 0; pn < num_parents; ++pn) DeleteLink (pn, child);

WARNING: Keep in mind that after deleting a link into node child, any list of parent nodes for child that was previously returned by GetNodeParents_bn is no longer valid.

Version:

This function is available in all versions.

See also:

AddLink_bn |  | Adds a link between two nodes
SwitchNodeParent_bn |  | Switches parents without changing conditional probabilities (can be used to disconnect link instead of deleting)

Example:

    The following function is available in NeticaEx.c:
    // Removes the single link from node 'parent' to node 'child'.
    // If there is no link from 'parent' to 'child', or more than one, it generates an error.
    //
    void DeleteLink (node_bn* parent, node_bn* child){
    	int pn = IndexOfNodeInList (parent, GetNodeParents_bn (child));
    	DeleteLink_bn (pn, child);
    }

Example 2:

    The following function is available in NeticaEx.c:
    // Removes all links entering node child
    // See DeleteLink_bn comment for explanation
    //
    void DeleteLinksEntering (node_bn* child){
        int pn, num_parents = LengthNodeList_bn (GetNodeParents_bn (child));
        for (pn = 0;  pn < num_parents;  ++pn)
            DeleteLink_bn (0, child);
    }