/** * Node.c --- This file contains functions for creating, * destroying, and modifying states of nodes. */ #include #include #include #include /*************************************************************************** * Low Level Node Utilities ***************************************************************************/ /** * This is a small utility function meant to be used from within * toString to determine if the pointer is live or not. */ SEXP RN_isNodeActive(SEXP node) { SEXP nodePtr, result; PROTECT(result=allocVector(LGLSXP,1)); LOGICAL(result)[0]=FALSE; PROTECT(nodePtr = getAttrib(node,nodeatt)); if (nodePtr && R_ExternalPtrAddr(nodePtr)) { LOGICAL(result)[0] = TRUE; } UNPROTECT(2); return result; } /** * Tests whether or not an object is a Netica Node. */ int isNeticaNode(SEXP obj) { SEXP klass; int result = FALSE; PROTECT(klass = getAttrib(obj,R_ClassSymbol)); R_len_t k, kk=length(klass); for (k=0; k 0) nn--; SetNodeLevels_bn(node_handle, nn, levels); } return(nd); } ////////////////////////////////////////////////////////////////// // Node Sets SEXP RN_ParseNodeSetString(net_bn *nt, bool_ns incSystem) { const char*rawsets=GetAllNodesets_bn(nt,incSystem,NULL); if (rawsets==NULL || strlen(rawsets)==0) { // Trap for zero length return (allocVector(STRSXP,0)); } char *sets = R_alloc(strlen(rawsets),sizeof(char)); sets = strcpy(sets,rawsets); SEXP result; int i, nsets = 1; for (i=0; i