function createNetwork(graphInstance, options, callback) {
  if (typeof options !== 'object') {
    options = {};
  }
  if (typeof options.subscribeGraph === 'undefined') {
    options.subscribeGraph = false;
  }

  // Choose legacy or modern network based on whether graph
  // subscription is needed
  const NetworkType = options.subscribeGraph ? LegacyNetwork : Network;
  const network = new NetworkType(graphInstance, options);

  // Ensure components are loaded before continuing
  const promise = network.loader.listComponents()
    .then(() => {
      if (options.delay) {
        // In case of delayed execution we don't wire it up
        return Promise.resolve(network);
      }
      const connected = /** @type {Promise<Network|LegacyNetwork>} */ (network.connect());
      return connected.then(() => network.start());
    });
  if (callback) {
    deprecated('Providing a callback to NoFlo.createNetwork is deprecated, use Promises');
    promise.then((nw) => {
      callback(null, nw);
    }, callback);
  }
  return promise;
}
@param {import("fbp-graph").Graph} graphInstance - Graph definition to build a Network for
@param {NetworkOptions} options - Network options
@param {NetworkCallback} [callback] - Legacy callback for the created Network
@returns {Promise<Network|LegacyNetwork>}