Skip to content

Commit 50c643c

Browse files
scan::print_graph() method
1 parent a6f92b0 commit 50c643c

File tree

3 files changed

+33
-50
lines changed

3 files changed

+33
-50
lines changed

include/ncd_aware_rank.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace singularity {
1616
const vector_t& initial_vector,
1717
const additional_matrices_vector& additional_matrices
1818
);
19+
virtual Graph create_graph(const matrix_t& m);
1920
private:
2021
parameters_t parameters;
2122
double_type const precision = 0.01;
@@ -39,7 +40,6 @@ namespace singularity {
3940
const vector_t& previous,
4041
const vector_t& teleportation
4142
);
42-
virtual Graph create_graph(const matrix_t& m);
4343
};
4444
}
4545

include/scan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace singularity {
7979
public:
8080
scan(double_type parameter_e, uint parameter_m);
8181
void process(Graph &g);
82-
void print_graph(Graph& g);
82+
void print_graph(std::ostream& output, Graph& g);
8383
private:
8484
double_type parameter_e;
8585
uint parameter_m;

scan.cpp

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -220,57 +220,40 @@ unsigned int id_generator::get_next_id() {
220220
return current_id ++;
221221
}
222222

223-
void scan::print_graph(Graph& g) {
223+
void scan::print_graph(std::ostream& output, Graph& g) {
224224

225-
//
226-
// dynamic_properties dp;
227-
//
228-
//
229-
// Graph::vertex_iterator current, end;
230-
//
231-
// tie (current, end) = vertices(g);
232-
// for (; current != end; current++) {
233-
// unsigned int index = get(vertex_index, g, *current);
234-
// unsigned int cluster_id = get(vertex_cluster_id, g, *current);
235-
// node_status_t status = get(vertex_status, g, *current);
236-
// std::string name;
237-
// switch (status) {
238-
// case node_status_member:
239-
// name = std::string("member");
240-
// break;
241-
// case node_status_hub:
242-
// name = std::string("hub");
243-
// break;
244-
// case node_status_outlier:
245-
// name = std::string("outlier");
246-
// break;
247-
// default:
248-
// name = std::string("?");
249-
// }
250-
//
251-
// std::string format = std::string("%d (%d) %s");
252-
// put(vertex_name, g, *current, name);
253-
// }
254-
//
255-
// dp.property("similarity", boost::get(edge_similarity, g));
256-
// dp.property("neighbours", boost::get(vertex_neighbour_count, g));
257-
// dp.property("node_id", boost::get(vertex_index, g));
258-
// dp.property("is_core", boost::get(vertex_is_core, g));
259-
// dp.property("cluster_id", boost::get(vertex_cluster_id, g));
260-
// dp.property("status", boost::get(vertex_name, g));
261-
//
262-
// write_graphviz_dp(std::cout, g, dp);
225+
dynamic_properties dp;
263226

264-
property_map<Graph, vertex_cluster_id_t>::type vertex_cluster_id_map = get(vertex_cluster_id, g);
265-
property_map<Graph, vertex_index_t>::type vertex_id_map = get(vertex_index, g);
266-
property_map<Graph, edge_similarity_t>::type edge_similarity_map = get(edge_similarity, g);
227+
Graph::vertex_iterator current, end;
267228

268-
dynamic_properties dp;
229+
tie (current, end) = boost::vertices(g);
230+
for (; current != end; current++) {
231+
node_status_t status = boost::get(vertex_status, g, *current);
232+
std::string name;
233+
switch (status) {
234+
case node_status_member:
235+
name = std::string("member");
236+
break;
237+
case node_status_hub:
238+
name = std::string("hub");
239+
break;
240+
case node_status_outlier:
241+
name = std::string("outlier");
242+
break;
243+
default:
244+
name = std::string("?");
245+
}
246+
247+
put(vertex_name, g, *current, name);
248+
}
269249

270-
dp.property("cluster_id", vertex_cluster_id_map);
271-
dp.property("id", vertex_id_map);
272-
dp.property("similarity", edge_similarity_map);
250+
dp.property("cluster_id", get(vertex_cluster_id, g));
251+
dp.property("id", get(vertex_index, g));
252+
dp.property("similarity", get(edge_similarity, g));
253+
dp.property("neighbours_count", get(vertex_neighbour_count, g));
254+
dp.property("is_core", get(vertex_is_core, g));
255+
dp.property("similarity_is_high", get(edge_similarity_is_high, g));
256+
dp.property("status", get(vertex_name, g));
273257

274-
write_graphviz_dp(std::cout, g, dp, "id");
258+
write_graphviz_dp(output, g, dp, "id");
275259
}
276-

0 commit comments

Comments
 (0)