5#ifndef LINE_API_WF_WF_LINK_MATRIX_H
6#define LINE_API_WF_WF_LINK_MATRIX_H
47int wf_id(
const Matrix<T>& linkMatrix, std::size_t i, std::size_t j) {
48 return static_cast<int>(num_traits<T>::to_double(linkMatrix(i, j)));
52void wf_check(
const Matrix<T>& linkMatrix) {
53 if (linkMatrix.cols() < 3)
54 throw InputError(
"wf: the link matrix needs three columns (from, to, probability)");
59std::map<int, std::vector<int>> wf_adjacency(
const Matrix<T>& linkMatrix) {
61 std::map<int, std::vector<int>> adj;
62 for (std::size_t i = 0; i < linkMatrix.rows(); ++i)
63 adj[wf_id(linkMatrix, i, 0)].push_back(wf_id(linkMatrix, i, 1));
69std::map<int, std::vector<std::pair<int, T>>> wf_adjacency_prob(
const Matrix<T>& linkMatrix) {
71 std::map<int, std::vector<std::pair<int, T>>> adj;
72 for (std::size_t i = 0; i < linkMatrix.rows(); ++i)
73 adj[wf_id(linkMatrix, i, 0)].push_back(
74 std::make_pair(wf_id(linkMatrix, i, 1), linkMatrix(i, 2)));
80std::map<int, std::vector<int>> wf_reverse_adjacency(
const Matrix<T>& linkMatrix) {
82 std::map<int, std::vector<int>> radj;
83 for (std::size_t i = 0; i < linkMatrix.rows(); ++i)
84 radj[wf_id(linkMatrix, i, 1)].push_back(wf_id(linkMatrix, i, 0));
The exception types the port throws.
Dense matrix and non-owning view.
Number-type abstraction for the templated API port.