public void generateRandomNetwork() throws Exception {
  if (m_otherBayesNet == null) {
    Init(m_nNrOfNodes,m_nCardinality);
    generateRandomNetworkStructure(m_nNrOfNodes,m_nNrOfArcs);
    generateRandomDistributions(m_nNrOfNodes,m_nCardinality);
  }
 else {
    m_nNrOfNodes=m_otherBayesNet.getNrOfNodes();
    m_ParentSets=m_otherBayesNet.getParentSets();
    m_Distributions=m_otherBayesNet.getDistributions();
    random=new Random(m_nSeed);
    ArrayList<Attribute> attInfo=new ArrayList<Attribute>(m_nNrOfNodes);
    for (int iNode=0; iNode < m_nNrOfNodes; iNode++) {
      int nValues=m_otherBayesNet.getCardinality(iNode);
      ArrayList<String> nomStrings=new ArrayList<String>(nValues + 1);
      for (int iValue=0; iValue < nValues; iValue++) {
        nomStrings.add(m_otherBayesNet.getNodeValue(iNode,iValue));
      }
      Attribute att=new Attribute(m_otherBayesNet.getNodeName(iNode),nomStrings);
      attInfo.add(att);
    }
    m_Instances=new Instances(m_otherBayesNet.getName(),attInfo,100);
    m_Instances.setClassIndex(m_nNrOfNodes - 1);
  }
}

public void generateRandomNetwork ( ) throws Exception { if ( m_otherBayesNet == null ) { Init ( m_nNrOfNodes , m_nCardinality ) ; generateRandomNetworkStructure ( m_nNrOfNodes , m_nNrOfArcs ) ; generateRandomDistributions ( m_nNrOfNodes , m_nCardinality ) ; } else { m_nNrOfNodes = m_otherBayesNet . getNrOfNodes ( ) ; m_ParentSets = m_otherBayesNet . getParentSets ( ) ; m_Distributions = m_otherBayesNet . getDistributions ( ) ; random = new Random ( m_nSeed ) ; ArrayList < Attribute > attInfo = new ArrayList < Attribute > ( m_nNrOfNodes ) ; for ( int iNode = 0 ; iNode < m_nNrOfNodes ; iNode ++ ) { int nValues = m_otherBayesNet . getCardinality ( iNode ) ; ArrayList < String > nomStrings = new ArrayList < String > ( nValues + 1 ) ; for ( int iValue = 0 ; iValue < nValues ; iValue ++ ) { nomStrings . add ( m_otherBayesNet . getNodeValue ( iNode , iValue ) ) ; } Attribute att = new Attribute ( m_otherBayesNet . getNodeName ( iNode ) , nomStrings ) ; attInfo . add ( att ) ; } m_Instances = new Instances ( m_otherBayesNet . getName ( ) , attInfo , 100 ) ; m_Instances . setClassIndex ( m_nNrOfNodes - 1 ) ; } }
generate random connected bayesian network with discrete nodes having all the same cardinality .
