arcsOut(G, n) is the set of triples in a graph G with subject n.
545345
def arcsOut(G: Graph, n: Node) -> RDFGraph:
    
    return RDFGraph(G.triples((n, None, None)))
1196767
public static <X, Y, Z> Triple<X, Y, Z> makeTriple(X x, Y y, Z z) {
    return new Triple<X, Y, Z>(x, y, z);
  }
1090402
public DataSet<Triplet<K, VV, EV>> getTriplets() {
		return this.getVertices()
			.join(this.getEdges()).where(0).equalTo(0)
			.with(new ProjectEdgeWithSrcValue<>())
				.name("Project edge with source value")
			.join(this.getVertices()).where(1).equalTo(0)
			.with(new ProjectEdgeWithVertexValues<>())
				.name("Project edge with vertex values");
	}
868274
public function isTriangle()
    {
        // exactly 3 (implicitly distinct) edges
        return (count($this->walk->getEdges()) === 3 &&
                // exactly three distinct vertices
                count($this->walk->getVertices()->getVerticesDistinct()) === 3 &&
                // this is actually a cycle
                $this->isCycle());
    }
393209
def bfs_multi_edges(G, source, reverse=False, keys=True, data=False):
    
    from collections import deque
    from functools import partial
    if reverse:
        G = G.reverse()
    edges_iter = partial(G.edges_iter, keys=keys, data=data)

    list(G.edges_iter('multitest', keys=True, data=True))

    visited_nodes = set([source])
    # visited_edges = set([])
    queue = deque([(source, edges_iter(source))])
    while queue:
        parent, edges = queue[0]
        try:
            edge = next(edges)
            edge_nodata = edge[0:3]
            # if edge_nodata not in visited_edges:
            yield edge
            # visited_edges.add(edge_nodata)
            child = edge_nodata[1]
            if child not in visited_nodes:
                visited_nodes.add(child)
                queue.append((child, edges_iter(child)))
        except StopIteration:
            queue.popleft()
598598
def transitive_reduction(self):
        
        combinations = []
        for node, edges in self.graph.items():
            combinations += [[node, edge] for edge in edges]

        while True:
            new_combinations = []
            for comb1 in combinations:
                for comb2 in combinations:
                    if not comb1[-1] == comb2[0]:
                        continue
                    new_entry = comb1 + comb2[1:]
                    if new_entry not in combinations:
                        new_combinations.append(new_entry)
            if not new_combinations:
                break
            combinations += new_combinations

        constructed = {(c[0], c[-1]) for c in combinations if len(c) != 2}
        for node, edges in self.graph.items():
            bad_nodes = {e for n, e in constructed if node == n}
            self.graph[node] = edges - bad_nodes
13891
def mutual_accessibility(graph):
    
    recursionlimit = getrecursionlimit()
    setrecursionlimit(max(len(graph.nodes())*2,recursionlimit))
    
    mutual_access = {}
    stack = []
    low = {}
        
    def visit(node):
        if node in low:
            return

        num = len(low)
        low[node] = num
        stack_pos = len(stack)
        stack.append(node)
        
        for successor in graph.neighbors(node):
            visit(successor)
            low[node] = min(low[node], low[successor])
        
        if num == low[node]:
            component = stack[stack_pos:]
            del stack[stack_pos:]
            component.sort()
            for each in component:
                mutual_access[each] = component

            for item in component:
                low[item] = len(graph)
    
    for node in graph:
        visit(node)
    
    setrecursionlimit(recursionlimit)
    return mutual_access
165255
def _get_triplet_value(self, graph, identity, rdf_type):
        
        value = graph.value(subject=identity, predicate=rdf_type)
        return value.toPython() if value is not None else value
722804
public static <T> List<T> getParents(DirectedGraph g, T n) {
        List<IndexedEdge> incoming = new ArrayList(g.incomingEdgesOf(n));
        Collections.sort(incoming);
        List<T> ret = new ArrayList();
        for(IndexedEdge e: incoming) {
            ret.add((T)e.source);
        }        
        return ret;
    }
470549
def triples(self, (s, p, o), context=None):
        
        named_graph = _get_named_graph(context)
        query_sets = _get_query_sets_for_object(o)

        filter_parameters = dict()
        if named_graph is not None:
            filter_parameters['context_id'] = named_graph.id
        if s:
            filter_parameters['subject'] = s
        if p:
            filter_parameters['predicate'] = p
        if o:
            filter_parameters['object'] = o

        query_sets = [qs.filter(**filter_parameters) for qs in query_sets]  # pylint: disable=W0142

        for qs in query_sets:
            for statement in qs:
                triple = statement.as_triple()
                yield triple, context
11884
function indexTriple(g, { subject, predicate, object }) {
  if (!workingPredicates.includes(predicate)) return;
  if (!(isIri(subject) && isIri(predicate)) || g[subject] && g[subject][predicate] && g[subject][predicate].includes(object)) return;

  upsert(g, subject, predicate, object);

  g.nTriples++;

  if (isIri(object)) upsert(g, object, `_${predicate}`, subject);
}
537549
def predicatesOut(G: Graph, n: Node) -> Set[TriplePredicate]:
    
    return {p for p, _ in G.predicate_objects(n)}
84136
def with_siblings(graph, outputs):
    """"""
    siblings = set()
    for node in outputs:
        siblings |= graph.siblings(node)
    return siblings
120639
boolean arbitaryMatching(final int[][] graph, final BitSet subset) {

        final BitSet unmatched = new BitSet();

        // indicates the deg of each vertex in unmatched subset
        final int[] deg = new int[graph.length];

        // queue/stack of vertices with deg1 vertices
        final int[] deg1 = new int[graph.length];
        int nd1 = 0, nMatched = 0;

        for (int v = subset.nextSetBit(0); v >= 0; v = subset.nextSetBit(v + 1)) {
            if (matched(v)) {
                assert subset.get(other(v));
                nMatched++;
                continue;
            }
            unmatched.set(v);
            for (int w : graph[v])
                if (subset.get(w) && unmatched(w)) deg[v]++;
            if (deg[v] == 1) deg1[nd1++] = v;
        }

        while (!unmatched.isEmpty()) {

            int v = -1;

            // attempt to select a vertex with degree = 1 (in matched set)
            while (nd1 > 0) {
                v = deg1[--nd1];
                if (unmatched.get(v)) break;
            }

            // no unmatched degree 1 vertex, select the first unmatched
            if (v < 0 || unmatched.get(v)) v = unmatched.nextSetBit(0);

            unmatched.clear(v);

            // find a unmatched edge and match it, adjacent degrees are updated
            for (final int w : graph[v]) {
                if (unmatched.get(w)) {
                    match(v, w);
                    nMatched += 2;
                    unmatched.clear(w);
                    // update neighbors of w and v (if needed)
                    for (final int u : graph[w])
                        if (--deg[u] == 1 && unmatched.get(u)) deg1[nd1++] = u;

                    // if deg == 1, w is the only neighbor
                    if (deg[v] > 1) {
                        for (final int u : graph[v])
                            if (--deg[u] == 1 && unmatched.get(u)) deg1[nd1++] = u;
                    }
                    break;
                }
            }
        }

        return nMatched == subset.cardinality();
    }
785393
public Graph<T> reduce(Graph<T> g) {
        boolean subgraph = nodes.containsAll(g.nodes) &&
                g.edges.keySet().stream()
                       .allMatch(u -> adjacentNodes(u).containsAll(g.adjacentNodes(u)));
        if (!subgraph) {
            throw new IllegalArgumentException(g + " is not a subgraph of " + this);
        }

        Builder<T> builder = new Builder<>();
        nodes.stream()
                .forEach(u -> {
                    builder.addNode(u);
                    // filter the edge if there exists a path from u to v in the given g
                    // or there exists another path from u to v in this graph
                    edges.get(u).stream()
                         .filter(v -> !g.pathExists(u, v) && !pathExists(u, v, false))
                         .forEach(v -> builder.addEdge(u, v));
                });

        // add the overlapped edges from this graph and the given g
        g.edges().keySet().stream()
                .forEach(u -> g.adjacentNodes(u).stream()
                                .filter(v -> isAdjacent(u, v))
                                .forEach(v -> builder.addEdge(u, v)));
        return builder.build().reduce();
    }
384686
public Graph<K, VV, EV> union(Graph<K, VV, EV> graph) {
		DataSet<Vertex<K, VV>> unionedVertices = graph
			.getVertices()
			.union(this.getVertices())
				.name("Vertices")
			.distinct()
				.name("Vertices");

		DataSet<Edge<K, EV>> unionedEdges = graph
			.getEdges()
			.union(this.getEdges())
				.name("Edges");

		return new Graph<>(unionedVertices, unionedEdges, this.context);
	}
1289095
def ArcSin(input_vertex: vertex_constructor_param_types, label: Optional[str]=None) -> Vertex:
    
    return Double(context.jvm_view().ArcSinVertex, label, cast_to_double_vertex(input_vertex))