src/DSGRN/SaveDatabaseJSON.py
def morse_graph_json(morse_graph):
    """Return json data for Morse graph."""

    def vertex_rank(u):
        """Return how many levels down of children u have."""
        children = [v for v in morse_graph.poset().children(u)]
        if len(children) == 0:
            return 0
        return 1 + max([vertex_rank(v) for v in children])

    # Get list of Morse nodes
    morse_nodes = range(morse_graph.poset().size())
    morse_graph_data = [] # Morse graph data
    for morse_node in morse_nodes:
        label = morse_graph.annotation(morse_node)[0]
        adjacencies = morse_graph.poset().children(morse_node)
        morse_node_data = {"node" : morse_node,
                           "rank" : vertex_rank(morse_node),
                           "label" : label,
                           "adjacencies" : adjacencies}
        morse_graph_data.append(morse_node_data)
    morse_graph_json_data = {"morse_graph" : morse_graph_data}
    return morse_graph_json_data
Return json data for Morse graph.
Return json data for Morse graph.
Return json data for Morse graph .
def morse_graph_json(morse_graph):
    def vertex_rank(u):
        children = [v for v in morse_graph.poset().children(u)]
        if len(children) == 0:
            return 0
        return 1 + max([vertex_rank(v) for v in children])
    morse_nodes = range(morse_graph.poset().size())
    morse_graph_data = [] 
    for morse_node in morse_nodes:
        label = morse_graph.annotation(morse_node)[0]
        adjacencies = morse_graph.poset().children(morse_node)
        morse_node_data = {"node" : morse_node,
                           "rank" : vertex_rank(morse_node),
                           "label" : label,
                           "adjacencies" : adjacencies}
        morse_graph_data.append(morse_node_data)
    morse_graph_json_data = {"morse_graph" : morse_graph_data}
    return morse_graph_json_data
def morse_graph_json ( morse_graph ) : def vertex_rank ( u ) : """Return how many levels down of children u have.""" children = [ v for v in morse_graph . poset ( ) . children ( u ) ] if len ( children ) == 0 : return 0 return 1 + max ( [ vertex_rank ( v ) for v in children ] ) morse_nodes = range ( morse_graph . poset ( ) . size ( ) ) morse_graph_data = [ ] for morse_node in morse_nodes : label = morse_graph . annotation ( morse_node ) [ 0 ] adjacencies = morse_graph . poset ( ) . children ( morse_node ) morse_node_data = { "node" : morse_node , "rank" : vertex_rank ( morse_node ) , "label" : label , "adjacencies" : adjacencies } morse_graph_data . append ( morse_node_data ) morse_graph_json_data = { "morse_graph" : morse_graph_data } return morse_graph_json_data
Return json data for Morse graph.
Return json data for Morse graph .
"""Return json data for Morse graph.""" """Return how many levels down of children u have.""" # Get list of Morse nodes # Morse graph data
morse_graph