void WriteNet_bn ( const net_bn*  net,   stream_ns*  file )

Writes net to a new file specified by file.

If file already exists, it is overwritten. The net is always saved using a "safe-save", which writes it to a new file, and then if there was no problem, it deletes the old file and changes the name of the new file to that of the old. That way there is no risk of data loss in case of an interruption due to a software error or hardware failure.

It is advised to write nets to files with extension ".dne" (i.e., the file name passed to NewStreamFile_ns ends with ".dne"). That way they can be more easily identified by other people and other programs, such as Netica Application.

If there are findings entered in net, you may want to retract them with RetractNetFindings_bn before writing net, since otherwise they will be saved in the file.

If the file size is very large, it may be because of large tables (such as CPTs). If these are defined by equations, it may be worthwhile to delete them with DeleteNodeTables_bn before writing the net to file, and restoring them with EquationToTable_bn after reading the net back in.

The net will be written in the DNET file format, which all versions of Netica API and Netica Application can read. See the Norsys website for more information on the DNET format (at location ftp://ftp.norsys.com/pub/users/norsys/dl/ look for file: DNET_File_Format.txt)

Version:

This function is available in all versions.

See also:

NewStreamFile_ns    Generates the required stream_ns
ReadNet_bn    Reads back the net saved
RetractNetFindings_bn    May want to retract findings before saving
WriteCase_bn    Just save the findings entered so far as a case
GetNetFileName_bn    Later retrieve the name of the file written to

Example:

  // Sets net2 to a copy of net1, but without its visual information
  //
  file = NewStreamFile_ns ("temp.dnet", env, NULL);
  WriteNet_bn (net1, file);
  net2 = ReadNet_bn (file, NO_VISUAL_INFO);
  if ((error = GetError_ns (env, WARNING_ERR, NULL)) != NULL)
      fprintf (stderr, "%s\n", ErrorMessage_ns (error));