Returns the edge that connects the head_id and tail_id nodes
554768
def edge_by_node(self, head, tail):
        
        for edge in self.out_edges(head):
            if self.tail(edge) == tail:
                return edge
        return None
95273
private void interiorLineBoundaryLine_(int half_edge, int id_a, int id_b,
			int cluster_index_a, int cluster_index_b, int predicate) {
		if (m_matrix[predicate] == 0)
			return;

		if (m_topo_graph.getHalfEdgeUserIndex(m_topo_graph
				.getHalfEdgePrev(m_topo_graph.getHalfEdgeTwin(half_edge)),
				m_visited_index) != 1) {
			int cluster = m_topo_graph.getHalfEdgeTo(half_edge);
			int clusterParentage = m_topo_graph.getClusterParentage(cluster);

			if ((clusterParentage & id_a) != 0
					&& (clusterParentage & id_b) != 0) {
				int index_a = m_topo_graph.getClusterUserIndex(cluster,
						cluster_index_a);
				int index_b = m_topo_graph.getClusterUserIndex(cluster,
						cluster_index_b);
				assert (index_a != -1);
				assert (index_b != -1);

				if ((index_a % 2 == 0) && (index_b % 2 != 0)) {
					assert ((m_topo_graph.getClusterParentage(cluster) & id_a) != 0 && (m_topo_graph
							.getClusterParentage(cluster) & id_b) != 0);
					m_matrix[predicate] = 0;
				}
			}
		}
	}
778037
private void boundaryAreaInteriorLine_(int half_edge, int id_a, int id_b,
			int cluster_index_b) {
		if (m_matrix[MatrixPredicate.BoundaryInterior] == 1)
			return;

		int parentage = m_topo_graph.getHalfEdgeParentage(half_edge);

		if ((parentage & id_a) != 0 && (parentage & id_b) != 0) {
			m_matrix[MatrixPredicate.BoundaryInterior] = 1;
			return;
		}

		if (m_matrix[MatrixPredicate.BoundaryInterior] != 0) {
			if (m_topo_graph.getHalfEdgeUserIndex(m_topo_graph
					.getHalfEdgePrev(m_topo_graph.getHalfEdgeTwin(half_edge)),
					m_visited_index) != 1) {
				int cluster = m_topo_graph.getHalfEdgeTo(half_edge);
				int clusterParentage = m_topo_graph
						.getClusterParentage(cluster);

				if ((clusterParentage & id_a) != 0) {
					int index = m_topo_graph.getClusterUserIndex(cluster,
							cluster_index_b);

					if ((clusterParentage & id_b) != 0 && (index % 2 == 0)) {
						assert (index != -1);
						m_matrix[MatrixPredicate.BoundaryInterior] = 0;
					}
				}
			}
		}
	}
506877
def node_to_edge(edges, directed=True):
    
    outgoing = defaultdict(set)
    incoming = defaultdict(set) if directed else outgoing
    nodes = set()
    for i, edge in enumerate(edges):
        a, b, = edge[:2]
        outgoing[a].add(i)
        incoming[b].add(i)
        nodes.add(a)
        nodes.add(b)
    nodes = sorted(nodes)
    if directed:
        return outgoing, incoming, nodes
    return outgoing, nodes
1353634
def connections(request, edges):
    
    edge_list, node_list = parse.graph_definition(edges)
    data = {'nodes': json.dumps(node_list), 'edges': json.dumps(edge_list)}
    return render_to_response('miner/connections.html', data)
89118
def get_edges(self):
        

        lr_x, lr_y = self.get_vec_lr()
        tb_x, tb_y = self.get_vec_tb()

        top_left = self.x, self.y
        top_right = self.x + lr_x, self.y + lr_y
        bottom_left = self.x + tb_x, self.y + tb_y
        bottom_right = self.x + lr_x + tb_x, self.y + lr_y + tb_y

        return top_left, top_right, bottom_left, bottom_right
719051
def _rm_gos_edges_rel(self, rm_goids, edges_rel):
        """"""
        edges_ret = {}
        for rname, edges_cur in edges_rel.items():
            edges_new = self._rm_gos_edges(rm_goids, edges_cur)
            if edges_new:
                edges_ret[rname] = edges_new
        return edges_ret
1266598
def _create_complete_graph(node_ids):
    
    g = nx.Graph()
    g.add_nodes_from(node_ids)
    for (i, j) in combinations(node_ids, 2):
        g.add_edge(i, j)
    return g
979495
def iterdfs(self, start, end=None, forward=True):
        
        visited, stack = set([start]), deque([start])

        if forward:
            get_edges = self.out_edges
            get_next = self.tail
        else:
            get_edges = self.inc_edges
            get_next = self.head

        while stack:
            curr_node = stack.pop()
            yield curr_node
            if curr_node == end:
                break
            for edge in sorted(get_edges(curr_node)):
                tail = get_next(edge)
                if tail not in visited:
                    visited.add(tail)
                    stack.append(tail)
955690
def reachable_nodes(self, p_id, p_recursive=True, p_reverse=False):
        
        stack = [p_id]
        visited = set()
        result = set()

        while len(stack):
            current = stack.pop()

            if current in visited or current not in self._edges:
                continue

            visited.add(current)

            if p_reverse:
                parents = [node for node, neighbors in self._edges.items()
                           if current in neighbors]

                stack = stack + parents
                result = result.union(parents)
            else:
                stack = stack + list(self._edges[current])
                result = result.union(self._edges[current])

            if not p_recursive:
                break

        return result
1320308
def p_edgesigs(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
1150367
function nodes(){
    var nodeSet = {};
    Object.keys(edges).forEach(function (u){
      nodeSet[u] = true;
      edges[u].forEach(function (v){
        nodeSet[v] = true;
      });
    });
    return Object.keys(nodeSet);
  }
465124
def assign_uuids_to_nodes_and_edges(self):
        
        for node in self.nodes(data=True):
            node[1]["id"] = str(uuid4())

        for edge in self.edges(data=True):
            edge[2]["id"] = str(uuid4())
660123
def path_tails(self, rr_id: str) -> str:
        

        return Tails.linked(self._dir_tails, rr_id)
757849
def get_edge_ids_by_node_ids(self, node_a, node_b):
        """"""
        # Check if the nodes are adjacent
        if not self.adjacent(node_a, node_b):
            return []

        # They're adjacent, so pull the list of edges from node_a and determine which ones point to node_b
        node = self.get_node(node_a)
        return [edge_id for edge_id in node['edges'] if self.get_edge(edge_id)['vertices'][1] == node_b]
1177902
def dfs_edges(G, start, depth_limit=1, get_only=True, get_path=False):
    """"""
    depth_limit = depth_limit - 1

    # creates unsigned int array (2 Byte)
    output_nodes = array('L')
    output_depth = array('I')
    # creates float array (4 Byte)
    output_weights = array('f')
    apath = []

    if G.node.get(start) is None:
        # raise KeyError('Start node not found')
        print('Start node not found')
        return output_nodes, output_weights, output_depth, apath

    visited = set()
    visited.add(start)

    # Save the start node with its data to the stack
    stack = [(start, G.edges_iter(start, data=True), 1.0)]
    visited.add(start)
    while stack:
        if len(output_nodes) > 80100100:
            print("To many nodes for: {}".format(start))
            del output_nodes
            del output_weights
            del output_depth
            output_nodes = array('L')
            output_depth = array('I')
            # creates float array (4 Byte)
            output_weights = array('f')
            gc.collect()
            break
        parent, children, weight = stack[-1]
        try:
            parent_, child, child_keys = next(children)
            # print "child: {}, parent_data: {}".format(child, parent_data)
            if child not in visited:
                weight = child_keys.get('weight', 1.0) * weight
                visited.add(child)

                if len(stack) >= depth_limit or weight <= 0.00001:
                    visited.remove(child)
                else:
                    stack.append((child, G.edges_iter(child, data=True),
                                 weight))

                # if its not and user.
                if get_only and child > 100000000000:
                    # if get_only and G.node[child].get('Type') != get_only:
                    continue

                output_nodes.append(child)
                output_weights.append(weight)
                output_depth.append(len(stack))
                if get_path:
                    apath.append([step[0] for step in stack])
        except StopIteration:
            stack.pop()
            visited.remove(parent)
            # if data.get('Type') == "Node":

    return output_nodes, output_weights, output_depth, apath
470656
def edges2nodes(edges):
    """"""
    nodes = []
    for e1, e2 in edges:
        nodes.append(e1)
        nodes.append(e2)
    nodedict = dict([(n, None) for n in nodes])
    justnodes = list(nodedict.keys())
    # justnodes.sort()
    justnodes = sorted(justnodes, key=lambda x: str(x[0]))
    return justnodes