Get edges where both the source and target are in the list of nodes.
332213
def _edge_both_nodes(nodes: List[Node]):
        """"""
        node_ids = [node.id for node in nodes]

        return and_(
            Edge.source_id.in_(node_ids),
            Edge.target_id.in_(node_ids),
        )
1175177
def move_edge_source(self, edge_id, node_a, node_b):
        """"""
        # Grab the edge
        edge = self.get_edge(edge_id)

        # Alter the vertices
        edge['vertices'] = (node_b, edge['vertices'][1])

        # Remove the edge from node_a
        node = self.get_node(node_a)
        node['edges'].remove(edge_id)

        # Add the edge to node_b
        node = self.get_node(node_b)
        node['edges'].append(edge_id)
323106
def fCZs(self):
        
        return {tuple(es.targets): es.fCZ for es in self.edges_specs}
300036
def from_edges(edges, source_key='source', target_key='target', weight_key='weight', directed=True):
    
    raw = list(map(lambda x: [x[source_key], x[target_key], int(x[weight_key])], edges))
    g = IGraph.TupleList(raw, weights=True, directed=directed)
    g.vs['indegree'] = g.degree(mode="in")
    g.vs['outdegree'] = g.degree(mode="out")
    g.vs['label'] = g.vs['name']
    if 'group' not in g.vs.attributes():
        g.vs['group'] = labels_to_groups(g.vs['label'])
    return g
684941
def _getImpliedEdges(roots):
        
        #Get nodes in job graph
        nodes = set()
        for root in roots:
            root._dfs(nodes)

        ##For each follow-on edge calculate the extra implied edges
        #Adjacency list of implied edges, i.e. map of jobs to lists of jobs
        #connected by an implied edge
        extraEdges = dict([(n, []) for n in nodes])
        for job in nodes:
            if len(job._followOns) > 0:
                #Get set of jobs connected by a directed path to job, starting
                #with a child edge
                reacheable = set()
                for child in job._children:
                    child._dfs(reacheable)
                #Now add extra edges
                for descendant in reacheable:
                    extraEdges[descendant] += job._followOns[:]
        return extraEdges
172536
def getEdges(npArr):
  """"""
  edges = np.concatenate(([0], npArr[:,0] + npArr[:,2]))
  return np.array([Decimal(str(i)) for i in edges])
231463
def nodes(self):
        """"""
        getnode = self._nodes.__getitem__
        return [getnode(nid) for nid in self._nodeids]
462720
private function getEdgeIndex( $sourceNode, $targetNode )
	{
		for( $i=0; $i<sizeof( $this->edges ); $i++ )
		{
			$edge = $this->edges[$i];
			$isSource = $edge->getSourceNode() == $sourceNode;
			$isTarget = $edge->getTargetNode() == $targetNode;
			if( $isSource && $isTarget )
				return $i;
		}
		return -1;
	}
1195888
def build_upstream_edge_predicate(nodes: Iterable[BaseEntity]) -> EdgePredicate:
    """"""
    nodes = set(nodes)

    def upstream_filter(graph: BELGraph, u: BaseEntity, v: BaseEntity, k: str) -> bool:
        """Pass for relations for which one of the given nodes is the object."""
        return v in nodes and graph[u][v][k][RELATION] in CAUSAL_RELATIONS

    return upstream_filter
296574
def get_edges_with_citation(self, citation: Citation) -> List[Edge]:
        """"""
        return self.session.query(Edge).join(Evidence).filter(Evidence.citation == citation)
1261728
def inc_edges(self, node):
        
        try:
            return list(self.nodes[node][0])
        except KeyError:
            raise GraphError('Invalid node %s' % node)

        return None
1121226
def get_c2ps(self):
        """"""
        c2ps = defaultdict(set)
        for goid_child, goid_parent in self.edges:
            c2ps[goid_child].add(goid_parent)
        return c2ps
34152
private List<ODocument> getEdgesBetweenModels(String source, String target) {
        ODocument from = getModel(source);
        ODocument to = getModel(target);
        String query = "select from E where out = ? AND in = ?";
        return graph.query(new OSQLSynchQuery<ODocument>(query), from, to);
    }
153338
def get_all_child_edges(self):
        """"""
        all_child_edges = set()
        for parent in self.children:
            all_child_edges.add((parent.item_id, self.item_id))
            all_child_edges |= parent.get_all_child_edges()
        return all_child_edges
12169
def get_shared_nodes(G1: nx.DiGraph, G2: nx.DiGraph) -> List[str]:
    """"""
    return list(set(G1.nodes()).intersection(set(G2.nodes())))
1331467
def select_neighbors_by_edge_attribute(docgraph, source,
                                       attribute=None, value=None, data=False):
    """"""
    assert isinstance(docgraph, MultiGraph)
    for neighbor_id in docgraph.neighbors_iter(source):
        edges = docgraph[source][neighbor_id].values()

        if attribute is None:
            has_attrib = True # don't filter neighbors
        else:
            has_attrib = any(attribute in edge for edge in edges)

        if has_attrib:
            if value is None:
                has_value = True
            elif isinstance(value, basestring):
                has_value = any(edge.get(attribute) == value
                                for edge in edges)
            else:  # ``value`` is a list/set/dict of values
                has_value = any(edge.get(attribute) == v
                                for edge in edges
                                for v in value)

            if has_value:
                if data:
                    yield (neighbor_id, docgraph.node[neighbor_id])
                else:
                    yield neighbor_id
325986
def get_all_parent_edges(self):
        """"""
        all_parent_edges = set()
        for parent in self.parents:
            all_parent_edges.add((self.item_id, parent.item_id))
            all_parent_edges |= parent.get_all_parent_edges()
        return all_parent_edges