tools/android/dependency_analysis/serialization.py
def create_json_obj_from_graph(graph_obj: graph.Graph) -> Dict:
    """Generates a JSON representation of the current graph.

    The list of nodes and edges is sorted in order to help with testing.
    Structure:
    {
        'nodes': [
            { see create_json_obj_from_node }, ...
        ],
        'edges': [
            {
                'begin': str,
                'end': str,
                'meta': { see Graph.get_edge_metadata },
            }, ...
        ],
    }
    """
    sorted_nodes = graph.sorted_nodes_by_name(graph_obj.nodes)
    json_nodes = [create_json_obj_from_node(node) for node in sorted_nodes]

    json_edges = []
    for begin_node, end_node in graph.sorted_edges_by_name(graph_obj.edges):
        edge_json_obj = {
            json_consts.BEGIN: begin_node.name,
            json_consts.END: end_node.name,
        }
        edge_meta = graph_obj.get_edge_metadata(begin_node, end_node)
        if edge_meta is not None:
            edge_json_obj[json_consts.META] = edge_meta
        json_edges.append(edge_json_obj)

    return {
        json_consts.NODES: json_nodes,
        json_consts.EDGES: json_edges,
    }
Generates a JSON representation of the current graph.

    The list of nodes and edges is sorted in order to help with testing.
    Structure:
    {
        'nodes': [
            { see create_json_obj_from_node }, ...
        ],
        'edges': [
            {
                'begin': str,
                'end': str,
                'meta': { see Graph.get_edge_metadata },
            }, ...
        ],
    }
    
Generates a JSON representation of the current graph.
The list of nodes and edges is sorted in order to help with testing.
Generates a JSON representation of the current graph . The list of nodes and edges is sorted in order to help with testing .
def create_json_obj_from_graph(graph_obj: graph.Graph) -> Dict:
    sorted_nodes = graph.sorted_nodes_by_name(graph_obj.nodes)
    json_nodes = [create_json_obj_from_node(node) for node in sorted_nodes]
    json_edges = []
    for begin_node, end_node in graph.sorted_edges_by_name(graph_obj.edges):
        edge_json_obj = {
            json_consts.BEGIN: begin_node.name,
            json_consts.END: end_node.name,
        }
        edge_meta = graph_obj.get_edge_metadata(begin_node, end_node)
        if edge_meta is not None:
            edge_json_obj[json_consts.META] = edge_meta
        json_edges.append(edge_json_obj)
    return {
        json_consts.NODES: json_nodes,
        json_consts.EDGES: json_edges,
    }
def create_json_obj_from_graph ( graph_obj : graph . Graph ) -> Dict : sorted_nodes = graph . sorted_nodes_by_name ( graph_obj . nodes ) json_nodes = [ create_json_obj_from_node ( node ) for node in sorted_nodes ] json_edges = [ ] for begin_node , end_node in graph . sorted_edges_by_name ( graph_obj . edges ) : edge_json_obj = { json_consts . BEGIN : begin_node . name , json_consts . END : end_node . name , } edge_meta = graph_obj . get_edge_metadata ( begin_node , end_node ) if edge_meta is not None : edge_json_obj [ json_consts . META ] = edge_meta json_edges . append ( edge_json_obj ) return { json_consts . NODES : json_nodes , json_consts . EDGES : json_edges , }
Generates a JSON representation of the current graph.
Generates a JSON representation of the current graph .
"""Generates a JSON representation of the current graph.

    The list of nodes and edges is sorted in order to help with testing.
    Structure:
    {
        'nodes': [
            { see create_json_obj_from_node }, ...
        ],
        'edges': [
            {
                'begin': str,
                'end': str,
                'meta': { see Graph.get_edge_metadata },
            }, ...
        ],
    }
    """
graph_obj
graph.Graph