-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertexBoundaryBetweennessCast.cpp
105 lines (80 loc) · 3.04 KB
/
VertexBoundaryBetweennessCast.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) 2023-2024 The Regents of the University of Michigan.
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
//
// This file is from the StructuralGT project, released under the BSD 3-Clause
// License.
#include "VertexBoundaryBetweennessCast.h"
#include "Util.h"
#include <igraph.h>
#include <stdio.h>
#include <stdlib.h>
#if IGRAPH_INTEGER_SIZE == 64
typedef int64_t IG_LONG;
#elif IGRAPH_INTEGER_SIZE == 32
typedef int32_t IG_LONG;
#endif
namespace interface {
// Default constructor
VertexBoundaryBetweennessCast::VertexBoundaryBetweennessCast() {}
VertexBoundaryBetweennessCast::~VertexBoundaryBetweennessCast() {}
void VertexBoundaryBetweennessCast::vertex_boundary_betweenness_compute() {
igraph_t *g = (igraph_t *)this->G_ptr;
num_vertices = igraph_vcount(g);
num_edges = igraph_ecount(g);
igraph_vector_int_t sources_vec, targets_vec;
igraph_vector_t res, weights_vec;
igraph_vector_init(&res, num_vertices);
igraph_vs_t ig_sources, ig_targets;
igraph_integer_t *sources_arr = (IG_LONG *)sources_ptr;
igraph_integer_t *targets_arr = (IG_LONG *)targets_ptr;
igraph_vector_int_init_array(&sources_vec, sources_arr, sources_len);
igraph_vector_int_init_array(&targets_vec, targets_arr, targets_len);
igraph_vs_vector(&ig_sources, &sources_vec);
igraph_vs_vector(&ig_targets, &targets_vec);
igraph_real_t *weights_arr = (double *)weights_ptr;
igraph_vector_init_array(&weights_vec, weights_arr, num_edges);
igraph_betweenness_subset(g, &res, /*igraph_vector_t *res*/
igraph_vss_all(), /*igraph_es_t eids*/
false, /*igraph_bool_t directed*/
ig_sources, /*igraph_vs_t sources*/
ig_targets, /*igraph_vs_t targets*/
&weights_vec); /*igraph_vector_t *weights*/
betweennesses <<= res;
igraph_vector_int_destroy(&sources_vec);
igraph_vector_int_destroy(&targets_vec);
igraph_vs_destroy(&ig_sources);
igraph_vs_destroy(&ig_targets);
igraph_destroy(g);
}
} // namespace interface