Esempio n. 1
0
def crawl_subgraph(node_summaries: Dict[str, NodeSummary],
                   function_summaries: Dict[str,
                                            Summary], g: pydot.Dot) -> str:
    """
    Creates the `NodeSummary` for all nodes in this subgraph and stores them in `node_summaries`

    :param node_summaries:
    :param function_summaries:
    :param g: The compiler-generated subgraph
    """
    nodes_list = g.get_nodes()

    for loop in g.get_subgraphs():
        node_name: str = crawl_subgraph(node_summaries, function_summaries,
                                        loop)
        node_summaries[node_name].type = NodeType.LOOP
        for k, v in node_summaries[node_name].variables.items():
            v.loop()

    for node in nodes_list:
        s = node_summaries[node.get_name()]
        s.status = SummaryState.PROCESSING

        lines: List[str] = node.get_attributes()['label'].split('\n')
        for i in range(
                1,
                len(lines) - 1
        ):  # Ignore the first and last lines wich I know don't have any calls
            parse_line(node_summaries, function_summaries, g, s, lines, i)

    first_node: str = nodes_list[0].get_name()
    deep_search_node(node_summaries, first_node)
    return first_node
Esempio n. 2
0
 def dot_to_subgraph(graph: pydot.Dot, label: str) -> pydot.Cluster:
     graph_s = pydot.Cluster(label, label=label)
     for node in graph.get_nodes():
         graph_s.add_node(node)
     for edge in graph.get_edges():
         graph_s.add_edge(edge)
     return graph_s
Esempio n. 3
0
 def dot_to_subgraph(graph: pydot.Dot, label: str) -> pydot.Cluster:
     graph_s = pydot.Cluster(label, label=label)
     graph_s.set_edge_defaults(style='dashed', color='gray', penwidth=1)
     for node in graph.get_nodes():
         graph_s.add_node(node)
     for edge in graph.get_edges():
         graph_s.add_edge(edge)
     return graph_s
Esempio n. 4
0
def set_common_attributes(graph: pydot.Dot) -> None:
    graph.set_layout("neato")
    graph.set_overlap("false")
    graph.set_splines("compound")
    graph.set_sep("+10")

    for node in graph.get_nodes():
        node.set_shape("circle")
        node.set_style("filled")
        node.set_height("0.15")
        node.set_fontsize("5")
        node.set_fixedsize("true")
        node.set_color("#5aa469")

    for edge in graph.get_edges():
        edge.set_penwidth("0.3")
for edge in Edges:
    GeneGraph[edge[0]]['adj'].append((edge[1], Edges[edge]))


G = Dot()

for node in GeneGraph:
    if node in ref_nodes:
        G.add_node(Node(name=node, width=str(GeneGraph[node]['length']), color='red'))
    else:
        G.add_node(Node(name=node, width=str(GeneGraph[node]['length']), color='blue'))

for node in GeneGraph:
    for _node in GeneGraph[node]['adj']:
        if (node, _node[0]) in ref_edges:
            G.add_edge(Edge(src=node, dst=_node[0], penwidth=str(np.sqrt(_node[1])), weight=str(_node[1]), color='red'))

        else:
            G.add_edge(Edge(src=node, dst=_node[0], penwidth=str(np.sqrt(_node[1])), weight=str(_node[1]), color='blue'))

for i in G.get_nodes():
    i.set_shape('box')
    i.set_style('filled')

G.set_rotate('landscape')
G.set_orientation('lL')
G.set_overlap('false')
G.set_splines('ortho')
G.set_rankdir('LR')
G.write(args.dot_save_way)
G.write_png(args.png_save_way)
Esempio n. 6
0
def SubNodes(subgraph: pydot.Dot, nodes: typing.List[typing.Any]):
  nodes.extend(subgraph.get_nodes())
            Gdot.add_edge(
                Edge(src=node,
                     dst=_node[0],
                     penwidth=str(np.sqrt(_node[1])),
                     weight=str(_node[1] * 1000),
                     color='red'))

        else:
            Gdot.add_edge(
                Edge(src=node,
                     dst=_node[0],
                     penwidth=str(np.sqrt(_node[1])),
                     weight=str(_node[1]),
                     color='royalblue'))
print('Your graph is written ...')
for i in Gdot.get_nodes():
    i.set_shape('box')
    i.set_style('filled')
G = nx.nx_pydot.from_pydot(Gdot)

if args.depth_lim == 'full':
    print('Making full graph ...')
    for node in Gdot.get_nodes():
        node.set_shape('box')
        node.set_style('rounded')
    Gdot.set_rotate('landscape')
    Gdot.set_orientation('lL')
    Gdot.set_splines('ortho')
    Gdot.set_rankdir('LR')
    if args.dot_save_way != None:
        Gdot.write(args.dot_save_way)