Given a list of faces (n,3), return a list of edges (n*3,2)

    Parameters
    -----------
    faces : (n, 3) int
      Vertex indices representing faces

    Returns
    -----------
    edges : (n*3, 2) int
      Vertex indices representing edges
424700
def faces_to_edges(faces, return_index=False):
    
    faces = np.asanyarray(faces)

    # each face has three edges
    edges = faces[:, [0, 1, 1, 2, 2, 0]].reshape((-1, 2))

    if return_index:
        # edges are in order of faces due to reshape
        face_index = np.tile(np.arange(len(faces)),
                             (3, 1)).T.reshape(-1)
        return edges, face_index
    return edges
761914
def _compute_edges_cells(self):
        
        if self.edges is None:
            self.create_edges()

        num_edges = len(self.edges["nodes"])

        counts = numpy.zeros(num_edges, dtype=int)
        fastfunc.add.at(
            counts,
            self.cells["edges"],
            numpy.ones(self.cells["edges"].shape, dtype=int),
        )

        # <https://stackoverflow.com/a/50395231/353337>
        edges_flat = self.cells["edges"].flat
        idx_sort = numpy.argsort(edges_flat)
        idx_start, count = grp_start_len(edges_flat[idx_sort])
        res1 = idx_sort[idx_start[count == 1]][:, numpy.newaxis]
        idx = idx_start[count == 2]
        res2 = numpy.column_stack([idx_sort[idx], idx_sort[idx + 1]])
        self._edges_cells = [
            [],  # no edges with zero adjacent cells
            res1 // 3,
            res2 // 3,
        ]
        # self._edges_local = [
        #     [],  # no edges with zero adjacent cells
        #     res1 % 3,
        #     res2 % 3,
        #     ]

        # For each edge, store the number of adjacent cells plus the index into
        # the respective edge array.
        self._edge_gid_to_edge_list = numpy.empty((num_edges, 2), dtype=int)
        self._edge_gid_to_edge_list[:, 0] = count
        c1 = count == 1
        l1 = numpy.sum(c1)
        self._edge_gid_to_edge_list[c1, 1] = numpy.arange(l1)
        c2 = count == 2
        l2 = numpy.sum(c2)
        self._edge_gid_to_edge_list[c2, 1] = numpy.arange(l2)
        assert l1 + l2 == len(count)

        return
1040279
def vertex_indices_in_segments(self, segments, ret_face_indices=False):
        '''
        
        '''
        import numpy as np
        import warnings

        face_indices = np.array([])
        vertex_indices = np.array([])
        if self.segm is not None:
            try:
                segments = [self.segm[name] for name in segments]
            except KeyError as e:
                raise ValueError('Unknown segments {}. Consier using Mesh.clean_segments on segments'.format(e.args[0]))
            face_indices = np.unique(np.concatenate(segments))
            vertex_indices = np.unique(np.ravel(self.f[face_indices]))
        else:
            warnings.warn('self.segm is None, will return empty array')

        if ret_face_indices:
            return vertex_indices, face_indices
        else:
            return vertex_indices
131630
def facets_by_vertex(self):
        
        if self._fbv_out is None:
            output = qhalf('Fv', self.halfspaces, self.interior_point)
            facets = []
            for l in output[1:]:
                facets.append([int(i) for i in l.split()[1:]])
            self._fbv_out = facets
        return self._fbv_out
305939
def faces(self):
        

        if self._faces is None:
            if self._vertices is None:
                return None
            self.triangulate()
        return self._faces
1322468
def get_edges(ont):
    
    logging.info("QUERYING:"+ont)
    edges = [(c,SUBCLASS_OF, d) for (c,d) in fetchall_isa(ont)]
    edges += fetchall_svf(ont)
    edges += [(c,SUBPROPERTY_OF, d) for (c,d) in fetchall_subPropertyOf(ont)]
    if len(edges) == 0:
        logging.warn("No edges for {}".format(ont))
    return edges
380457
def compute_number_edges(function):
    
    n = 0
    for node in function.nodes:
        n += len(node.sons)
    return n
442933
def getEdges(self, edges, inEdges = True, outEdges = True, rawResults = False) :
        """"""
        try :
            return edges.getEdges(self, inEdges, outEdges, rawResults)
        except AttributeError :
            raise AttributeError("%s does not seem to be a valid Edges object" % edges)
1010877
def __calculate_adjacency_lists(graph):
    """"""
    adj = {}
    for node in graph.get_all_node_ids():
        neighbors = graph.neighbors(node)
        adj[node] = neighbors
    return adj
289816
def _tri_from_edge(self, edge):
        
        edge = tuple(edge)
        p1 = self._edges_lookup.get(edge, None)
        p2 = self._edges_lookup.get(edge[::-1], None)
        if p1 is None:
            if p2 is None:
                raise RuntimeError("No tris connected to edge %r" % (edge,))
            return edge + (p2,)
        elif p2 is None:
            return edge + (p1,)
        else:
            raise RuntimeError("Two triangles connected to edge %r" % (edge,))
765231
def _edge_mapping(G):
    
    edge_mapping = {edge: idx for idx, edge in enumerate(G.edges)}
    edge_mapping.update({(e1, e0): idx for (e0, e1), idx in edge_mapping.items()})
    return edge_mapping
352012
def face(sign, lon):
    
    faces = FACES[sign]
    if lon < 10:
        return faces[0]
    elif lon < 20:
        return faces[1]
    else:
        return faces[2]
628091
def edges(self):
        # TODO: check docstring
        
        for i in sorted(self._matrix.keys(), key=lambda x:x.name()):
            for j in sorted(self._matrix[i].keys(), key=lambda x:x.name()):
                if i != j:
                    yield (i, j)
920978
private static IBond[] neighbors(int v, int[][] g, EdgeToBondMap bondMap) {
        int[]   ws    = g[v];
        IBond[] bonds = new IBond[ws.length];
        for (int i = 0; i < ws.length; i++) {
            bonds[i] = bondMap.get(v, ws[i]);
        }
        return bonds;
    }
661063
def find_edges(a):
    
    edges = a[1:] == a[:-1]
    tops = np.where(~edges)[0] + 1
    tops = np.append(0, tops)
    values = a[tops]

    return tops, values
935011
def vertices(self):
        

        if self._faces is None:
            if self._vertices is None:
                return None
            self.triangulate()
        return self._vertices
83718
def vertices_per_edge(self):
        """"""
        import numpy as np
        return np.asarray([vertices_in_common(e[0], e[1]) for e in self.f[self.faces_per_edge]])