def _traverse_hier_in_graph(self, G):
    '\n        Recusively reads all hierachies in the graph and convert them to dictionary\n        '
    for (node, attr) in G.nodes(data=True):
        if (('sub_graph' in attr) and attr['sub_graph']):
            logger.debug(f"Traversing sub graph: {node} {attr['inst_type']} {attr['ports']}")
            sub_ports = []
            ports_weight = {}
            for (sub_node, sub_attr) in attr['sub_graph'].nodes(data=True):
                if ('net_type' in sub_attr):
                    if (sub_attr['net_type'] == 'external'):
                        sub_ports.append(sub_node)
                        ports_weight[sub_node] = []
                        for nbr in list(attr['sub_graph'].neighbors(sub_node)):
                            ports_weight[sub_node].append(attr['sub_graph'].get_edge_data(sub_node, nbr)['weight'])
            logger.debug(f"external ports: {sub_ports}, {attr['connection']}, {ports_weight}")
            const = self.const_parse.read_user_const(attr['inst_type'])
            self.hier_graph_dict[attr['inst_type']] = {'graph': attr['sub_graph'], 'ports': sub_ports, 'const': const, 'ports_weight': ports_weight}
            self._traverse_hier_in_graph(attr['sub_graph'])
Recusively reads all hierachies in the graph and convert them to dictionary
def _traverse_hier_in_graph(self, G):
    '\n        \n        '
    for (node, attr) in G.nodes(data=True):
        if (('sub_graph' in attr) and attr['sub_graph']):
            logger.debug(f"Traversing sub graph: {node} {attr['inst_type']} {attr['ports']}")
            sub_ports = []
            ports_weight = {}
            for (sub_node, sub_attr) in attr['sub_graph'].nodes(data=True):
                if ('net_type' in sub_attr):
                    if (sub_attr['net_type'] == 'external'):
                        sub_ports.append(sub_node)
                        ports_weight[sub_node] = []
                        for nbr in list(attr['sub_graph'].neighbors(sub_node)):
                            ports_weight[sub_node].append(attr['sub_graph'].get_edge_data(sub_node, nbr)['weight'])
            logger.debug(f"external ports: {sub_ports}, {attr['connection']}, {ports_weight}")
            const = self.const_parse.read_user_const(attr['inst_type'])
            self.hier_graph_dict[attr['inst_type']] = {'graph': attr['sub_graph'], 'ports': sub_ports, 'const': const, 'ports_weight': ports_weight}
            self._traverse_hier_in_graph(attr['sub_graph'])