def find_ports(port_map: list, attrs: dict):
     """ Find all ports in a given port map with specified attributes """
     result = []
     for i, port in enumerate(port_map):
         if dict_includes(port, attrs):
             result.append(i)
     return result
Esempio n. 2
0
 def find_internal_layer_id(graph: Graph, virtual_id):
     internal_nodes = list(
         filter(
             lambda d: dict_includes(d[1],
                                     {'internal_layer_id': virtual_id}),
             graph.nodes(data=True)))
     assert len(internal_nodes) == 1, 'Nodes: {}, virtual_id: {}'.format(
         internal_nodes, virtual_id)
     return internal_nodes[0][0]
Esempio n. 3
0
def exit_bound_edges(graph: Graph, sources: list, end_node_attrs: dict):
    """
    Finds all descendant nodes for each node from 'sources' that have given attributes from end_node_attrs.
    For each found node, create a tuple with a given element from 'source' and the node.
    """
    result = []
    for node in sources:
        for end_node in nx.descendants(graph, node):
            if dict_includes(big=graph.node[end_node], sub_dict=end_node_attrs):
                result.append((node, end_node, 0, {}))
    return result
Esempio n. 4
0
def node_match(data1: dict, data2: dict):
    return dict_includes(data1, data2)
Esempio n. 5
0
def node_match(data1: dict, data2: dict):
    # We have to skip _in_ports/_out_ports attributes for comparison as they are not comparable
    return dict_includes(data1,
                         data2,
                         skip_attr_names=['_in_ports', '_out_ports'])