scran_graph_cluster
Graph-based clustering of cells
Loading...
Searching...
No Matches
edges_to_graph.hpp
Go to the documentation of this file.
1#ifndef SCRAN_GRAPH_CLUSTER_EDGES_TO_GRAPH_HPP
2#define SCRAN_GRAPH_CLUSTER_EDGES_TO_GRAPH_HPP
3
4#include <cstddef>
5
6#include "raiigraph/raiigraph.hpp"
7#include "sanisizer/sanisizer.hpp"
8
9#include "igraph.h"
10
16namespace scran_graph_cluster {
17
33template<typename Vertex_>
34raiigraph::Graph edges_to_graph(const std::size_t double_edges, const Vertex_* const edges, const std::size_t num_vertices, const igraph_bool_t directed) {
35 if constexpr(std::is_same<Vertex_, igraph_integer_t>::value) {
36 igraph_vector_int_t edge_view{};
37 igraph_vector_int_view(&edge_view, edges, sanisizer::cast<igraph_integer_t>(double_edges));
38 return raiigraph::Graph(&edge_view, num_vertices, directed);
39 } else {
40 auto tmp = sanisizer::create<raiigraph::IntegerVector>(double_edges);
41 auto& payload = *(tmp.get());
42 for (std::size_t x = 0; x < double_edges; ++x) {
43 VECTOR(payload)[x] = edges[x];
44 }
45 return raiigraph::Graph(tmp, num_vertices, directed);
46 }
47}
48
49}
50
51#endif
Graph-based clustering of single-cell data.
Definition build_snn_graph.hpp:22
raiigraph::Graph edges_to_graph(const std::size_t double_edges, const Vertex_ *const edges, const std::size_t num_vertices, const igraph_bool_t directed)
Definition edges_to_graph.hpp:34