node_bn* NodeNamed_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.

See also:

GetNodeName_bn  (inverse function) Returns the name of the node

Example:

// Like NodeNamed_bn, but generates an error if the name doesn't exist.
//
node_bn* NodeNamed (char* node_name, net_bn* net){
    node_bn* node = NodeNamed_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:
// 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 = NodeNamed_bn (name, net);
        if (node == NULL)  return -1;
        return IndexOfNodeInList_bn (node, nodes, 0);
    }
}