MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / graph_to_linkgraph

Function graph_to_linkgraph

cpp_easygraph/common/utils.cpp:30–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30Graph_L graph_to_linkgraph(Graph &G, bool if_directed, std::string weight_key, bool is_deg, bool is_reverse){
31 int node_num = G.node.size();
32 const std::vector<graph_edge>& edges = G._get_edges(if_directed);
33 int edges_num = edges.size();
34 Graph_L G_l(node_num, if_directed, is_deg);
35 for(register int i = 0; i < edges_num; i++){
36 graph_edge e = edges[i];
37 edge_attr_dict_factory& edge_attr = e.attr;
38 weight_t edge_weight = edge_attr.find(weight_key) != edge_attr.end() ? edge_attr[weight_key] : 1;
39 if(is_reverse){
40 std::swap(e.u, e.v);
41 }
42 G_l.add_weighted_edge(e.u, e.v, edge_weight);
43 if (!if_directed){
44 G_l.add_weighted_edge(e.v, e.u, edge_weight);
45 }
46 }
47 return G_l;
48}

Callers 11

Graph_generate_linkgraphFunction · 0.85
_pagerankFunction · 0.85
core_decompositionFunction · 0.85
_dijkstra_multisourceFunction · 0.85
_spfaFunction · 0.85
closeness_centralityFunction · 0.85
betweenness_centralityFunction · 0.85

Calls 3

_get_edgesMethod · 0.80
sizeMethod · 0.45
add_weighted_edgeMethod · 0.45

Tested by

no test coverage detected