Returns the model_data based on the given model.

    Parameters
    ----------
    model: BayesianModel instance
        Model to write

    Return
    ------
    model_data: dict
        dictionary containing model data of the given model.

    Examples
    --------
    >>> model_data = pgmpy.readwrite.get_model_data(model)
    >>> writer.get_model_data(model)

def get_probmodel_data(model):
    """
    Returns the model_data based on the given model.

    Parameters
    ----------
    model: BayesianModel instance
        Model to write

    Return
    ------
    model_data: dict
        dictionary containing model data of the given model.

    Examples
    --------
    >>> model_data = pgmpy.readwrite.get_model_data(model)
    >>> writer.get_model_data(model)
    """
    if not isinstance(model, BayesianModel):
        raise TypeError("Model must an instance of BayesianModel.")
    model_data = {'probnet': {'type': 'BayesianNetwork', 'Variables': {}}}

    variables = model.nodes()
    for var in variables:
        model_data['probnet']['Variables'][var] = model.node[var]

    model_data['probnet']['edges'] = {}
    edges = model.edges()
    for edge in edges:
        model_data['probnet']['edges'][str(edge)] = model.adj[edge[0]][edge[1]]

    model_data['probnet']['Potentials'] = []
    cpds = model.get_cpds()
    for cpd in cpds:
        potential_dict = {}
        potential_dict['Variables'] = {}
        evidence = cpd.variables[:0:-1]
        if evidence:
            potential_dict['Variables'][cpd.variable] = evidence
        else:
            potential_dict['Variables'][cpd.variable] = []
        potential_dict['type'] = "Table"
        potential_dict['role'] = "conditionalProbability"
        potential_dict['Values'] = " ".join([str(val) for val in cpd.values.ravel().astype(float)]) + " "
        model_data['probnet']['Potentials'].append(potential_dict)

    return model_data