src/DSGRN/SaveDatabaseJSON.py
def network_json(network):
    """Return json data for network."""
    nodes = [] # Get network nodes
    for d in range(network.size()):
        node = {"id" : network.name(d)}
        nodes.append(node)
    # Get network edges
    edges = [(u, v) for u in range(network.size()) for v in network.outputs(u)]
    links = []
    for (u, v) in edges:
        edge_type = 1 if network.interaction(u, v) else -1
        link = {"source" : network.name(u),
                "target" : network.name(v),
                "type": edge_type}
        links.append(link)
    network_json_data = {"network" : {"nodes" : nodes, "links" : links}}
    return network_json_data
Return json data for network.
Return json data for network.
Return json data for network .
def network_json(network):
    nodes = [] 
    for d in range(network.size()):
        node = {"id" : network.name(d)}
        nodes.append(node)
    edges = [(u, v) for u in range(network.size()) for v in network.outputs(u)]
    links = []
    for (u, v) in edges:
        edge_type = 1 if network.interaction(u, v) else -1
        link = {"source" : network.name(u),
                "target" : network.name(v),
                "type": edge_type}
        links.append(link)
    network_json_data = {"network" : {"nodes" : nodes, "links" : links}}
    return network_json_data
def network_json ( network ) : nodes = [ ] for d in range ( network . size ( ) ) : node = { "id" : network . name ( d ) } nodes . append ( node ) edges = [ ( u , v ) for u in range ( network . size ( ) ) for v in network . outputs ( u ) ] links = [ ] for ( u , v ) in edges : edge_type = 1 if network . interaction ( u , v ) else - 1 link = { "source" : network . name ( u ) , "target" : network . name ( v ) , "type" : edge_type } links . append ( link ) network_json_data = { "network" : { "nodes" : nodes , "links" : links } } return network_json_data
Return json data for network.
Return json data for network .
"""Return json data for network.""" # Get network nodes # Get network edges
network