Find all nodes in a subset.
    
        We assume the oboInOwl encoding of subsets, and subset IDs are IRIs
556409
def extract_subset(self, subset):
        
    
        # note subsets have an unusual encoding
        query = """
        prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
        SELECT ?c WHERE {{
        GRAPH <{g}>  {{
        ?c oboInOwl:inSubset ?s
        FILTER regex(?s,'#{s}$','i')
        }}
        }}
        """.format(s=subset, g=self.graph_name)
        bindings = run_sparql(query)
        return [r['c']['value'] for r in bindings]
457301
def compute_dominators(nodes):
    '''
        
    '''
    changed = True

    for n in nodes:
        n.dominators = set(nodes)

    while changed:
        changed = False

        for node in nodes:
            new_set = intersection_predecessor(node).union({node})
            if new_set != node.dominators:
                node.dominators = new_set
                changed = True

    # compute immediate dominator
    for node in nodes:
        idom_candidates = set(node.dominators)
        idom_candidates.remove(node)

        for dominator in node.dominators:
            if dominator != node:
                [idom_candidates.remove(d) for d in dominator.dominators if d in idom_candidates and d!=dominator]

        assert len(idom_candidates)<=1
        if idom_candidates:
            idom = idom_candidates.pop()
            node.immediate_dominator = idom
            idom.dominator_successors.add(node)
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]
1314783
def get_nodes(graph: BELGraph, node_predicates: NodePredicates) -> Set[BaseEntity]:
    """"""
    return set(filter_nodes(graph, node_predicates=node_predicates))
702521
def _node_set(self) -> List["InstanceNode"]:
        """"""
        return list(self) if isinstance(self.value, ArrayValue) else [self]
961688
def get_subgraph_by_induction(graph, nodes: Iterable[BaseEntity]):
    
    nodes = tuple(nodes)

    if all(node not in graph for node in nodes):
        return

    return subgraph(graph, nodes)
384063
void findLargestAnglesForAllNodes() {
		for (int i = 0; i < listInfo.size(); i++) {
			NodeInfo info = listInfo.get(i);

			if( info.edges.size < 2 )
				continue;

			for (int k = 0, j = info.edges.size-1; k < info.edges.size; j=k,k++) {
				double angleA = info.edges.get(j).angle;
				double angleB = info.edges.get(k).angle;

				double distance = UtilAngle.distanceCCW(angleA,angleB);

				if( distance > info.angleBetween ) {
					info.angleBetween = distance;
					info.left = info.edges.get(j).target;
					info.right = info.edges.get(k).target;
				}
			}
		}
	}
979688
function collectNodeIds(stmt) {
  var ids = {},
      stack = [],
      curr;

  var push = stack.push.bind(stack);

  push(stmt);
  while(stack.length) {
    curr = stack.pop();
    switch(curr.type) {
      case "node": ids[curr.id] = true; break;
      case "edge": _.each(curr.elems, push); break;
      case "subgraph": _.each(curr.stmts, push); break;
    }
  }

  return _.keys(ids);
}
1242562
def get_nodes_by_selector(self, selector, not_selector=None):
        
        nodes = self.parsed(selector)

        if not_selector is not None:
            nodes = nodes.not_(not_selector)

        return nodes
322309
def find_string_ids(self, substring, suffix_tree_id, limit=None):
        

        # Find an edge for the substring.
        edge, ln = self.find_substring_edge(substring=substring, suffix_tree_id=suffix_tree_id)

        # If there isn't an edge, return an empty set.
        if edge is None:
            return set()

        # Get all the string IDs beneath the edge's destination node.
        string_ids = get_string_ids(
            node_id=edge.dest_node_id,
            node_repo=self.node_repo,
            node_child_collection_repo=self.node_child_collection_repo,
            stringid_collection_repo=self.stringid_collection_repo,
            length_until_end=edge.length + 1 - ln,
            limit=limit
        )

        # Return a set of string IDs.
        return set(string_ids)
561240
def deep_nodes(self, allnodes=None):
        
        allnodes = (allnodes or [])
        for (node, node_) in ((node, node_) for (node, node_) in\
            self.iteritems() if not node in allnodes):
            allnodes.append(node)
            node_.deep_nodes(allnodes)
        return allnodes
515079
public Set<String> getAllNodeIDs() {
		HashSet<String> ids = new HashSet<>(nodes.keySet());
		ids.add(nodeID);
		return ids;
	}
658439
def get_all_edge_nodes(self):
        """"""
        edge_nodes = set(e for es in self.edges for e in es)
        for edges in self.edges_rel.values():
            rel_nodes = set(e for es in edges for e in es)
            edge_nodes.update(rel_nodes)
        return edge_nodes
463747
def _find_node_by_indices(self, point):
        "
        path_index, node_index = point
        path = self.paths[int(path_index)]
        node = path.nodes[int(node_index)]
        return node
393067
def get_intersectionsbysubsets(df,cols_fracby2vals,cols_subset,col_ids):
    
    for col_fracby in cols_fracby2vals:
        val=cols_fracby2vals[col_fracby]
        ids=df.loc[(df[col_fracby]==val),col_ids].dropna().unique()
        for col_subset in cols_subset:
            for subset in dropna(df[col_subset].unique()):
                ids_subset=df.loc[(df[col_subset]==subset),col_ids].dropna().unique()
                df.loc[(df[col_subset]==subset),f'P {col_fracby} {col_subset}']=len(set(ids_subset).intersection(ids))/len(ids_subset)
    return df
853323
def is_coord_subset(subset, superset, atol=1e-8):
    
    c1 = np.array(subset)
    c2 = np.array(superset)
    is_close = np.all(np.abs(c1[:, None, :] - c2[None, :, :]) < atol, axis=-1)
    any_close = np.any(is_close, axis=-1)
    return np.all(any_close)
169578
private static int[] getComplement(int[] subset, int[] fullset) {
        int size = fullset.length - subset.length;

        // Returns null if no complement
        if (size < 1) {
            return null;
        }

        // Otherwsise define combination array and determine complement
        int[] complement = new int[size];
        int index = 0;
        for (int i = 0; i < fullset.length; i++) {
            int item = fullset[i];
            boolean member = false;
            for (int j = 0; j < subset.length; j++) {
                if (item == subset[j]) {
                    member = true;
                    break;
                }
            }

            if (!member) {
                complement[index++] = item;
            }

        }

        return complement;
    }