scran_graph_cluster
Graph-based clustering of cells
Loading...
Searching...
No Matches
cluster_walktrap.hpp
Go to the documentation of this file.
1#ifndef SCRAN_CLUSTER_WALKTRAP_HPP
2#define SCRAN_CLUSTER_WALKTRAP_HPP
3
4#include <vector>
5#include <algorithm>
6
7#include "raiigraph/raiigraph.hpp"
8#include "igraph.h"
9
15namespace scran_graph_cluster {
16
25 int steps = 4;
26
30 bool report_merges = true;
31
35 bool report_modularity = true;
36};
37
46 int status = 0;
47
51 raiigraph::IntegerVector membership;
52
60 raiigraph::IntegerMatrix merges;
61
67 raiigraph::RealVector modularity;
68};
69
82 auto membership = output.membership.get();
83 auto modularity = (options.report_modularity ? output.modularity.get() : NULL);
84 auto merges = (options.report_merges ? output.merges.get() : NULL);
85 output.status = igraph_community_walktrap(graph, weights, options.steps, merges, modularity, membership);
86}
87
98inline ClusterWalktrapResults cluster_walktrap(const raiigraph::Graph& graph, const std::vector<igraph_real_t>& weights, const ClusterWalktrapOptions& options) {
99 // No need to free this, as it's just a view.
101 igraph_vector_view(&weight_view, weights.data(), weights.size());
102
105 return output;
106}
107
108}
109
110#endif
Graph-based clustering of single-cell data.
Definition build_snn_graph.hpp:20
void build_snn_graph(size_t num_cells, GetNeighbors_ get_neighbors, GetIndex_ get_index, const BuildSnnGraphOptions &options, BuildSnnGraphResults< Node_, Weight_ > &output)
Definition build_snn_graph.hpp:133
void cluster_walktrap(const igraph_t *graph, const igraph_vector_t *weights, const ClusterWalktrapOptions &options, ClusterWalktrapResults &output)
Definition cluster_walktrap.hpp:81
Options for cluster_walktrap().
Definition cluster_walktrap.hpp:20
int steps
Definition cluster_walktrap.hpp:25
bool report_merges
Definition cluster_walktrap.hpp:30
bool report_modularity
Definition cluster_walktrap.hpp:35
Result of cluster_walktrap().
Definition cluster_walktrap.hpp:41
raiigraph::IntegerVector membership
Definition cluster_walktrap.hpp:51
int status
Definition cluster_walktrap.hpp:46
raiigraph::IntegerMatrix merges
Definition cluster_walktrap.hpp:60
raiigraph::RealVector modularity
Definition cluster_walktrap.hpp:67