Find the accepted states
        Args:
            graph (DFA): The DFA states
        Return:
            list: Returns the list of the accepted states
492437
def _get_accepted(self, graph):
        
        accepted = []
        for state in graph.states:
            if state.final != TropicalWeight(float('inf')):
                accepted.append(state)
        return accepted
116711
def get_annotation_values(graph, annotation: str) -> Set[str]:
    
    return set(iter_annotation_values(graph, annotation))
1337726
def sort_qualified_edges(graph) -> Iterable[EdgeTuple]:
    
    qualified_edges = (
        (u, v, k, d)
        for u, v, k, d in graph.edges(keys=True, data=True)
        if graph.has_edge_citation(u, v, k) and graph.has_edge_evidence(u, v, k)
    )
    return sorted(qualified_edges, key=_sort_qualified_edges_helper)
21094
def ind_nodes(self, graph=None):
        
        if graph is None:
            graph = self.graph

        dependent_nodes = set(
            node for dependents in six.itervalues(graph) for node in dependents
        )
        return [node for node in graph.keys() if node not in dependent_nodes]
106856
def to_graph(self):
        
        edges = set()
        for clause, target in self.edges_iter():
            for source, signature in clause:
                edges.add((source, target, signature))

        return Graph.from_tuples(edges)
1299175
def _read_component_definitions(self, graph):
        
        for e in self._get_elements(graph, SBOL.ComponentDefinition):
            identity = e[0]
            # Store component values in dict
            c = self._get_rdf_identified(graph, identity)
            c['roles'] = self._get_triplet_value_list(graph, identity, SBOL.role)
            c['types'] = self._get_triplet_value_list(graph, identity, SBOL.type)
            obj = ComponentDefinition(**c)
            self._components[identity.toPython()] = obj
            self._collection_store[identity.toPython()] = obj
683126
def filterGraph(graph, node_fnc):
		
		nodes = filter(lambda l: node_fnc(l), graph.nodes())
		edges = {}

		gedges = graph.edges()
		for u in gedges:
			if u not in nodes:
				continue
			for v in gedges[u]:
				if v not in nodes:
					continue
				try:
					edges[u].append(v)
				except KeyError:
					edges[u] = [v]

		return Graph(nodes, edges)
368847
def get_parameters(self, graph=None):
        
        g = graph if graph is not None else self.tf_graph

        with g.as_default():
            with tf.Session() as self.tf_session:
                self.tf_saver.restore(self.tf_session, self.model_path)

                return {
                    'W': self.W.eval(),
                    'bh_': self.bh_.eval(),
                    'bv_': self.bv_.eval()
                }
726152
def legal_graph(graph):
    '''
    '''

    descriptor = graph.extract_descriptor()
    skips = descriptor.skip_connections
    if len(skips) != len(set(skips)):
        return False
    return True
588645
def isa_from_graph(graph: nx.Graph, oneq_type='Xhalves', twoq_type='CZ') -> ISA:
    
    all_qubits = list(range(max(graph.nodes) + 1))
    qubits = [Qubit(i, type=oneq_type, dead=i not in graph.nodes) for i in all_qubits]
    edges = [Edge(sorted((a, b)), type=twoq_type, dead=False) for a, b in graph.edges]
    return ISA(qubits, edges)
1018052
def get_connected_components(graph):
    

    list_of_components = []
    component = []  # Not strictly necessary due to the while loop structure, but it helps the automated analysis tools

    # Store a list of all unreached vertices
    unreached = set(graph.get_all_node_ids())
    to_explore = deque()

    while len(unreached) > 0:
        # This happens when we reach the end of a connected component and still have more vertices to search through
        if len(to_explore) == 0:
            n = unreached.pop()
            unreached.add(n)
            to_explore.append(n)
            component = []
            list_of_components.append(component)

        # This is the BFS that searches for connected vertices
        while len(to_explore) > 0:
            n = to_explore.pop()
            if n in unreached:
                component.append(n)
                unreached.remove(n)
                nodes = graph.neighbors(n)
                for n in nodes:
                    if n in unreached:
                        to_explore.append(n)

    return list_of_components
896326
def get_dependants(self, run):
        
        if run in self._graph.nodes():
            return list(self._graph.successors(run))
        else:
            return []
1071417
def _annotation_iter_helper(graph) -> Iterable[str]:
    
    return (
        key
        for _, _, data in graph.edges(data=True)
        if ANNOTATIONS in data
        for key in data[ANNOTATIONS]
    )
1261728
def inc_edges(self, node):
        
        try:
            return list(self.nodes[node][0])
        except KeyError:
            raise GraphError('Invalid node %s' % node)

        return None
770214
def participating_ec_states(self):
        '''

        '''
        with self._mutex:
            if not self._participating_ec_states:
                if self.participating_ecs:
                    states = []
                    for ec in self.participating_ecs:
                        states.append(self._get_ec_state(ec))
                    self._participating_ec_states = states
                else:
                    self._participating_ec_states = []
        return self._participating_ec_states
54398
def _delta(self, graph, cur_state, char):
        
        for arc in cur_state.arcs:
            if graph.isyms.find(arc.ilabel) == char:
                return graph[arc.nextstate]
        return None
1064441
def definitions(self):
        

        defs = set()

        if self._simplified:
            graph = self._ddg.simplified_data_graph
        else:
            graph = self._ddg.data_graph

        for n in graph.nodes():  # type: ProgramVariable
            if n.location.ins_addr == self._insn_addr:
                defs.add(DDGViewItem(self._ddg, n, simplified=self._simplified))

        return list(defs)