Get the SubGraph that matches the predicate

@param sd SameDiff instance the function belongs to
@param rootFn   Function that defines the root of the subgraph
@return The subgraph that matches the predicate
194684
public SubGraph getSubGraph(SameDiff sd, DifferentialFunction rootFn){
        Preconditions.checkState(matches(sd, rootFn), "Root function does not match predicate");

        List<DifferentialFunction> childNodes = new ArrayList<>();
        //Need to work out child nodes
        if(!opInputSubgraphPredicates.isEmpty()){
            for(Map.Entry<Integer,OpPredicate> entry : opInputSubgraphPredicates.entrySet()){
                OpPredicate p2 = entry.getValue();
                SDVariable arg = rootFn.arg(entry.getKey());
                DifferentialFunction df = sd.getVariableOutputFunction(arg.getVarName());
                if(df != null){
                    childNodes.add(df);

                    if(p2 instanceof SubGraphPredicate){
                        SubGraph sg = ((SubGraphPredicate) p2).getSubGraph(sd, df);
                        childNodes.addAll(sg.childNodes);
                    }
                }
            }
        }

        SubGraph sg = SubGraph.builder()
                .sameDiff(sd)
                .rootNode(rootFn)
                .childNodes(childNodes)
                .build();

        return sg;
    }
545408
def is_frond(u, v, dfs_data):
    """"""
    d_u = D(u, dfs_data)
    d_v = D(v, dfs_data)
    edge_id = dfs_data['graph'].get_first_edge_id_by_node_ids(u, v)
    return True if dfs_data['edge_lookup'][edge_id] == 'backedge' and d_v < d_u else False
378650
@Override
    public boolean isSubgraph(boolean shouldMatchBonds) {

        CDKRMapHandler rmap = new CDKRMapHandler();

        try {

            if ((source.getAtomCount() == target.getAtomCount()) && source.getBondCount() == target.getBondCount()) {
                rOnPFlag = true;
                rmap.calculateIsomorphs(source, target, shouldMatchBonds);

            } else if (source.getAtomCount() > target.getAtomCount() && source.getBondCount() != target.getBondCount()) {
                rOnPFlag = true;
                rmap.calculateSubGraphs(source, target, shouldMatchBonds);

            } else {
                rOnPFlag = false;
                rmap.calculateSubGraphs(target, source, shouldMatchBonds);
            }

            setAllMapping();
            setAllAtomMapping();
            setFirstMapping();
            setFirstAtomMapping();

        } catch (CDKException e) {
            rmap = null;
            //            System.err.println("WARNING: graphContainer: most probably time out error ");
        }

        return !getFirstMapping().isEmpty();
    }
772797
public static boolean compare(Document d1, Document d2) throws MarshalException {
		d1.normalize();
		d2.normalize();
		return d1.isEqualNode(d2);
	}
285846
def tarjan_recursif(graph):
    
    global sccp, waiting, dfs_time, dfs_num
    sccp = []
    waiting = []
    waits = [False] * len(graph)
    dfs_time = 0
    dfs_num = [None] * len(graph)

    def dfs(node):
        global sccp, waiting, dfs_time, dfs_num
        waiting.append(node)           # new node is waiting
        waits[node] = True
        dfs_num[node] = dfs_time       # mark visit
        dfs_time += 1
        dfs_min = dfs_num[node]        # compute dfs_min
        for neighbor in graph[node]:
            if dfs_num[neighbor] is None:
                dfs_min = min(dfs_min, dfs(neighbor))
            elif waits[neighbor] and dfs_min > dfs_num[neighbor]:
                dfs_min = dfs_num[neighbor]
        if dfs_min == dfs_num[node]:   # representative of a component
            sccp.append([])            # make a component
            while True:                # add waiting nodes
                u = waiting.pop()
                waits[u] = False
                sccp[-1].append(u)
                if u == node:          # until representative
                    break
        return dfs_min

    for node in range(len(graph)):
        if dfs_num[node] is None:
            dfs(node)
    return sccp
146725
private DependencyTreeNode getNextNode(DependencyRelation prev,
                                           DependencyRelation cur) {
        return (prev.headNode() == cur.headNode() 
                || prev.dependentNode() ==  cur.headNode())
            ? cur.dependentNode()
            : cur.headNode();
    }
992977
def get_sdf(identifier, namespace='cid', domain='compound',operation=None, searchtype=None, **kwargs):
    """"""
    try:
        return get(identifier, namespace, domain, operation, 'SDF', searchtype, **kwargs).decode()
    except NotFoundError as e:
        log.info(e)
        return None
514877
@Override
    public INDArray[] executeGraph(SameDiff sd) {
        return executeGraph(sd, ExecutorConfiguration.builder().outputMode(OutputMode.IMPLICIT).executionMode(ExecutionMode.SEQUENTIAL).profilingMode(OpExecutioner.ProfilingMode.DISABLED).build());
    }
338477
public final boolean sameNodeAs(Node other)
  {

    if (!(other instanceof DTMNodeProxy))
      return false;

    DTMNodeProxy that = (DTMNodeProxy) other;

    return this.dtm == that.dtm && this.node == that.node;
  }
454349
@SuppressWarnings("unchecked")
    public static <T, K> Join<T, K> findJoinedType(Root<T> root, Class<T> rootClass, Class<K> joinClass) {
        Join<T, K> join = null;
        for (Join<T, ?> j : root.getJoins()) {
            if (j.getJavaType().equals(joinClass)) {
                join = (Join<T, K>) j;
            }
        }
        return join;
    }
205933
function matchAdjacentSiblings(nodes, predicate, root) {
  return nodes.reduce((matches, node) => {
    const parent = findParentNode(root, node);
    // If there's no parent, there's no siblings
    if (!parent) {
      return matches;
    }
    const parentChildren = childrenOfNode(parent);
    const nodeIndex = parentChildren.indexOf(node);
    const adjacentSibling = parentChildren[nodeIndex + 1];
    // No sibling
    if (!adjacentSibling) {
      return matches;
    }
    if (predicate(adjacentSibling)) {
      matches.push(adjacentSibling);
    }
    return matches;
  }, []);
}
1042304
public Set<T> dfs(Set<T> roots) {
        Deque<T> deque = new LinkedList<>(roots);
        Set<T> visited = new HashSet<>();
        while (!deque.isEmpty()) {
            T u = deque.pop();
            if (!visited.contains(u)) {
                visited.add(u);
                if (contains(u)) {
                    adjacentNodes(u).stream()
                        .filter(v -> !visited.contains(v))
                        .forEach(deque::push);
                }
            }
        }
        return visited;
    }
529117
public IntArrayList getConnectedComponentsT2() {
        boolean[] marked1 = new boolean[nodes1.size()];
        boolean[] marked2 = new boolean[nodes2.size()];
        
        IntArrayList roots = new IntArrayList();
        for (int t2=0; t2<nodes2.size(); t2++) {
            if (!marked2[t2]) {
                roots.add(t2);
                
                // Depth first search.
                dfs(t2, false, marked1, marked2, null);
            }
        }
        return roots;
    }
428795
public List<NodePair> match(GraphPair graphPair) {
        Validate.argumentIsNotNull(graphPair);

        List<NodePair> pairs = new ArrayList<>();
        Map<GlobalId, ObjectNode> rightMap = asMap(graphPair.getRightNodeSet());

        for (ObjectNode left : graphPair.getLeftNodeSet()) {
            GlobalId key = left.getGlobalId();
            if (rightMap.containsKey(key)) {
                pairs.add(new RealNodePair(left, rightMap.get(key)));
            }
        }

        return pairs;
    }
1018727
def getStartNodes(fdefs,calls):
    ''''''
    s=[]
    for source in fdefs:
        for fn in fdefs[source]:
            inboundEdges=False
            for call in calls:
                if call.target==fn:
                    inboundEdges=True
            if not inboundEdges:
                s.append(fn)
    return s
68302
public Rdn getRdn(final LDAPNode node) throws FrameworkException, LdapInvalidDnException {

		String name = node.getUserProvidedName();
		if (name == null) {

			name = node.getRdn();
		}

		return new Rdn(schemaManager, name);
	}
1089714
public static OrganigramNode findTreeNode(OrganigramNode searchRoot, OrganigramNode selection) {
        if (selection == null || searchRoot == null) {
            return null;
        }

        if (searchRoot.equals(selection)) {
            return searchRoot;
        }

        if (searchRoot.getChildren() != null) {
            for (OrganigramNode child : searchRoot.getChildren()) {
                OrganigramNode childResult = findTreeNode(child, selection);
                if (childResult != null) {
                    return childResult;
                }
            }
        }

        return null;
    }