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

node_bn* GetNodeNamed_bn ( | const char* name, const net_bn* net )

Returns the node of net which has a name exactly matching name (case sensitive comparison). If there is no such node, it will return NULL (without generating an error).

name can be any string; it need not be a legal IDname (of course if is not legal, NULL will be returned).

To search a node list for a node with a given name, see the FindNodeNamed example below.

Netica won't modify or free the passed name string.

Version:

This function is available in all versions. In versions previous to 3.05, this function was named NodeNamed_bn.

See also:

GetNodeName_bn |  | (inverse function) Returns the name of the node

Example:

    The following function is available in NeticaEx.c:
    // Like GetNodeNamed_bn, but generates an error if the name doesn't exist.
    // In versions prior to 3.05 this function was called NodeNamed
    //
    node_bn* GetNode (char* node_name, net_bn* net){
        node_bn* node = GetNodeNamed_bn (node_name, net);
        if (node == NULL)
            NewError (env, 0, ERROR_ERR,      // for NewError, see NewError_ns
                         "NodeNamed: There is no node named '%s' in net '%s'",
                         node_name, GetNetName_bn (net));
        return node;
    }

Example 2:

    The following function is available in NeticaEx.c:
    // Returns the index of the node identified by name in the list nodes,
    //   or -1 if it doesn't appear.
    // All of nodes must be in the same net.
    //
    int FindNodeNamed (const char* name, const nodelist_bn* nodes){
        if (LengthNodeList_bn (nodes) == 0)  return -1;
        else {
            net_bn* net = GetNodeNet_bn (NthNode_bn (nodes, 0));
            node_bn* node = GetNodeNamed_bn (name, net);
            if (node == NULL)  return -1;
            return IndexOfNodeInList_bn (node, nodes, 0);
        }
    }