Args:
            graph (DFA): The DFA states
            access_strings_map (list): a dict containing all the access strings for each state
        Return:
            list: SMI transition table
423536
def _init_smi(self, graph, access_strings_map):
        
        smi = []
        for selected_state in sorted(graph.states, key=attrgetter('initial'), reverse=True):
            # Initially gather all transitions of the state into a dictionary
            transitions_map = defaultdict(list)
            for character in self.alphabet:
                destination_state = self._delta(graph, selected_state, character)
                transitions_map[destination_state.stateid].append(character)

            chars_in_smi = []
            sorted_transitions = sorted(
                transitions_map.items(),
                key=lambda x: len(
                    x[1]))

            if len(sorted_transitions) == 1:
                # Just put 1 symbol is enough all other'input_string will be generalized
                # by the guardgen algorithm
                chars_in_smi.append(self.alphabet[0])
            else:
                # Otherwise insert in smi_vector all transitions as explicit except
                # the one from the sink transition where we add just enough
                # explicity transitions to make sure that this state will be
                # selected as the sink state.
                #
                # If no transition has a clear advantage in terms of symbols then
                # just add all transitions in explicit form because it may be the
                # case the guardgen() will generalize in the wrong transition.
                for (_, char_list) in sorted_transitions[:-1]:
                    chars_in_smi += char_list

                sink_chars = len(sorted_transitions[-2][1]) + 1
                chars_in_smi.extend(sorted_transitions[-1][1][:sink_chars])

            access_string = access_strings_map[selected_state.stateid]
            smi.extend([access_string + character for character in chars_in_smi])
        return smi
863028
def get_strings(self):
        
        seen = []
        for digest, dx in self.analyzed_vms.items():
            if dx in seen:
                continue
            seen.append(dx)
            yield digest, self.analyzed_digest[digest], dx.get_strings_analysis()
397266
private Map<String, Integer> getTranscriptionalControls(
            Collection<KamEdge> edges) {
        Map<String, Integer> controlCountMap = new HashMap<String, Integer>();
        for (KamEdge edge : edges) {
            if (edge.getTargetNode().getFunctionType() == FunctionEnum.RNA_ABUNDANCE
                    && isCausal(edge)) {
                if (controlCountMap
                        .containsKey(edge.getSourceNode().getLabel())) {
                    int count =
                            controlCountMap
                                    .get(edge.getSourceNode().getLabel());
                    count = count + 1;
                    controlCountMap.put(edge.getSourceNode().getLabel(), count);
                } else {
                    controlCountMap.put(edge.getSourceNode().getLabel(), 1);
                }
            }
        }

        return controlCountMap;
    }
1061884
def refsDecl(self):
        
        for refsDecl in self.graph.objects(self.asNode(), RDF_NAMESPACES.TEI.replacementPattern):
            return str(refsDecl)
1338557
def t_string_NGRAPH(t):
    "
    global __STRING

    P = {' ': 0, "'": 2, '.': 8, ':': 10}
    N = {' ': 0, "'": 1, '.': 4, ':': 5}

    __STRING += chr(128 + P[t.value[1]] + N[t.value[2]])
640481
def get_output_nodes(G: nx.DiGraph) -> List[str]:
    
    return [n for n, d in G.out_degree() if d == 0]
770865
def to_string(self):
        

        src = self.parse_node_ref( self.get_source() )
        dst = self.parse_node_ref( self.get_destination() )
        
        if isinstance(src, frozendict):
            edge = [ Subgraph(obj_dict=src).to_string() ]
        elif isinstance(src, (int, long)):
            edge = [ str(src) ]
        else:
            edge = [ src ]
        
        if	(self.get_parent_graph() and
            self.get_parent_graph().get_top_graph_type() and
            self.get_parent_graph().get_top_graph_type() == 'digraph' ):

            edge.append( '->' )
            
        else:
            edge.append( '--' )
            
        if isinstance(dst, frozendict):
            edge.append( Subgraph(obj_dict=dst).to_string() )
        elif isinstance(dst, (int, long)):
            edge.append( str(dst) )
        else:
            edge.append( dst )


        edge_attr = list()
        
        for attr, value in self.obj_dict['attributes'].iteritems():
        
            if value is not None:
                edge_attr.append( '%s=%s' % (attr, quote_if_necessary(value) ) )
            else:
                edge_attr.append( attr )

        edge_attr = ', '.join(edge_attr)
        
        if edge_attr:
            edge.append( ' [' + edge_attr + ']' )

        return ' '.join(edge) + ';'
974143
def strids2ids(tokens: Iterable[str]) -> List[int]:
    
    return list(map(int, tokens))
1363123
def command_u2a(string, vargs):
    
    try:
        l = ARPABETMapper().map_unicode_string(
            unicode_string=string,
            ignore=vargs["ignore"],
            single_char_parsing=vargs["single_char_parsing"],
            return_as_list=True
        )
        print(vargs["separator"].join(l))
    except ValueError as exc:
        print_error(str(exc))
850105
def get_string(self):
        
        graph_string = self.graph.to_string()
        graph_string = graph_string.replace('\\N', '\\n')
        return graph_string
776545
def dfa_json_importer(input_file: str) -> dict:
    
    file = open(input_file)
    json_file = json.load(file)

    transitions = {}  # key [state ∈ states, action ∈ alphabet]
    #                   value [arriving state ∈ states]
    for (origin, action, destination) in json_file['transitions']:
        transitions[origin, action] = destination

    dfa = {
        'alphabet': set(json_file['alphabet']),
        'states': set(json_file['states']),
        'initial_state': json_file['initial_state'],
        'accepting_states': set(json_file['accepting_states']),
        'transitions': transitions
    }
    return dfa
789117
def read_graph_from_string(txt):
    
    if not txt.startswith('{'):
        return read_dot(txt)  # standard dot format

    def conv(value):
        if isinstance(value, basestring):
            return '"' + value + '"'
        else:
            return value

    # our compacted format
    doc = literal_eval(txt)
    g = digraph()

    for attrs, values in doc.get("nodes", []):
        attrs = [(k, conv(v)) for k, v in attrs]

        for value in values:
            if isinstance(value, basestring):
                node_name = value
                attrs_ = attrs
            else:
                node_name, label = value
                attrs_ = attrs + [("label", conv(label))]

            g.add_node(node_name, attrs=attrs_)

    for attrs, values in doc.get("edges", []):
        attrs_ = [(k, conv(v)) for k, v in attrs]

        for value in values:
            if len(value) == 3:
                edge = value[:2]
                label = value[-1]
            else:
                edge = value
                label = ''

            g.add_edge(edge, label=label, attrs=attrs_)

    return g
1257386
def _build_table(self) -> Dict[State, Tuple[Multiplex, ...]]:
        
        result: Dict[State, Tuple[Multiplex, ...]] = {}
        for state in self.influence_graph.all_states():
            result[state] = tuple(multiplex for multiplex in self.influence_graph.multiplexes 
                                  if multiplex.is_active(state))
        return result
625682
def get_strings_from_utterance(tokenized_utterance: List[Token]) -> Dict[str, List[int]]:
    
    string_linking_scores: Dict[str, List[int]] = defaultdict(list)

    for index, token in enumerate(tokenized_utterance):
        for string in ATIS_TRIGGER_DICT.get(token.text.lower(), []):
            string_linking_scores[string].append(index)

    token_bigrams = bigrams([token.text for token in tokenized_utterance])
    for index, token_bigram in enumerate(token_bigrams):
        for string in ATIS_TRIGGER_DICT.get(' '.join(token_bigram).lower(), []):
            string_linking_scores[string].extend([index,
                                                  index + 1])

    trigrams = ngrams([token.text for token in tokenized_utterance], 3)
    for index, trigram in enumerate(trigrams):
        if trigram[0] == 'st':
            natural_language_key = f'st. {trigram[2]}'.lower()
        else:
            natural_language_key = ' '.join(trigram).lower()
        for string in ATIS_TRIGGER_DICT.get(natural_language_key, []):
            string_linking_scores[string].extend([index,
                                                  index + 1,
                                                  index + 2])
    return string_linking_scores
741124
def get_all_nodes(self, addr, is_syscall=None, anyaddr=False):
        
        results = [ ]

        for cfg_node in self.graph.nodes():
            if cfg_node.addr == addr or (anyaddr and
                                         cfg_node.size is not None and
                                         cfg_node.addr <= addr < (cfg_node.addr + cfg_node.size)
                                         ):
                if is_syscall and cfg_node.is_syscall:
                    results.append(cfg_node)
                elif is_syscall is False and not cfg_node.is_syscall:
                    results.append(cfg_node)
                else:
                    results.append(cfg_node)

        return results
1156211
def layerset2str(discoursegraph):
    
    for node_id in discoursegraph:
        discoursegraph.node[node_id]['layers'] = \
            str(discoursegraph.node[node_id]['layers'])
    for (from_id, to_id) in discoursegraph.edges_iter():
        # there might be multiple edges between 2 nodes
        edge_dict = discoursegraph.edge[from_id][to_id]
        for edge_id in edge_dict:
            edge_dict[edge_id]['layers'] = \
                str(edge_dict[edge_id]['layers'])
1206061
def connectionMap(self, scene, nodes):
        
        output = {}
        connections = scene.connections()
        
        for node in nodes:
            inputs = []
            outputs = []
            
            for connection in connections:
                in_node = connection.inputNode()
                out_node = connection.outputNode()
                
                if node == in_node:
                    inputs.append(out_node)
                elif node == out_node:
                    outputs.append(in_node)
                
            output[node] = (inputs, outputs)
        
        return output