Changeset 0075ec
- Timestamp:
- 07/02/07 20:33:37 (6 years ago)
- Branches:
- master, python3
- Children:
- 393242
- Parents:
- ba2aee
- git-author:
- Tiago de Paula Peixoto <tiago@…> (07/02/07 20:33:37)
- git-committer:
- Tiago de Paula Peixoto <tiago@…> (07/02/07 20:33:37)
- Location:
- src
- Files:
-
- 4 edited
-
graph-tool (modified) (4 diffs)
-
graph/graph.hh (modified) (1 diff)
-
graph/graph_betweenness.cc (modified) (4 diffs)
-
graph/graph_bind.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/graph-tool
rba2aee r0075ec 114 114 statistics.add_option("--minimum-spanning-tree", action="callback", callback=push_option, type="string", metavar="[WEIGHT|]PROPERTY", help="mark the minimum spanning tree edges in PROPERTY") 115 115 statistics.add_option("--line-graph", action="callback", callback=push_option, type="string", metavar="FILE[|FORMAT]", help="save the corresponding line graph to FILE") 116 statistics.add_option("--betweenness-centrality", action="callback", callback=push_option, type="string", metavar="VERTEX_BETWEENESS[EDGE_BETWEENESS]", help="calculate and store the vertex and/or edge betweenness centrality") 116 statistics.add_option("--betweenness-centrality", action="callback", callback=push_option, type="string", metavar="VERTEX_BETWEENESS[|EDGE_BETWEENESS[|WEIGHT]]", help="calculate and store the vertex and/or edge betweenness centrality") 117 statistics.add_option("--central-point-dominance", action="callback", callback=push_option, type="string", metavar="VERTEX_BETWEENESS|FILE", help="calculate central point dominance, given the VERTEX_BETWEENESS vertex property") 118 117 119 118 120 correlations = parser.add_option_group("Correlations") … … 125 127 126 128 clustering = parser.add_option_group("Clustering") 127 clustering.add_option("-- set-local-clustering-to-property", action="callback", callback=push_option, type="string", metavar="PROPERTY", help="set the local clustering coefficient to vertex property")129 clustering.add_option("--local-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="PROPERTY", help="set the local clustering coefficient to vertex property") 128 130 clustering.add_option("--global-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="FILE", help="get the global clustering coefficient") 129 clustering.add_option("-- set-extended-clustering-to-property", action="callback", callback=push_option, type="string", metavar="PREFIX|MAX", help="set the extended clustering coefficients c1 to cMAX to vertex properties PREFIX1 to PREFIXMAX")131 clustering.add_option("--extended-clustering-coefficient", action="callback", callback=push_option, type="string", metavar="PREFIX|MAX", help="set the extended clustering coefficients c1 to cMAX to vertex properties PREFIX1 to PREFIXMAX") 130 132 131 133 layout = parser.add_option_group("Layout") … … 523 525 weight = "" 524 526 graph.GetBetweenness(weight, vertex_centrality, edge_centrality) 527 elif opt.name == "central-point-dominance": 528 values = parse_values(opt.value) 529 if len(values) != 2: 530 raise OptionError(opt.name, "invalid value '%s'" % opt.value) 531 if just_file: 532 return None 533 return (graph.GetCentralPointDominance(values[0]), values[1]) 525 534 elif opt.name == "vertex-correlation-histogram": 526 535 values = parse_values(opt.value) … … 601 610 ret = "%f\t%f" % (avg, dev) 602 611 return (ret, opt.value) 603 elif opt.name == " set-local-clustering-to-property":612 elif opt.name == "local-clustering-coefficient": 604 613 if just_file: 605 614 return None 606 615 graph.SetLocalClusteringToProperty(opt.value) 607 elif opt.name == " set-extended-clustering-to-property":616 elif opt.name == "extended-clustering-coefficient": 608 617 if just_file: 609 618 return None -
src/graph/graph.hh
rba2aee r0075ec 99 99 void GetLineGraph(std::string out_file, std::string format); 100 100 void GetBetweenness(std::string weight, std::string edge_betweenness, std::string vertex_betweenness); 101 101 double GetCentralPointDominance(std::string vertex_betweenness); 102 102 103 // community structure 103 104 enum comm_corr_t -
src/graph/graph_betweenness.cc
rba2aee r0075ec 36 36 using namespace graph_tool; 37 37 38 template <class Graph, class VertexBetweenness, class EdgeBetweenness> 39 void normalize_betweenness(const Graph& g, VertexBetweenness vertex_betweenness, EdgeBetweenness edge_betweenness) 40 { 41 size_t n = HardNumVertices()(g); 42 double factor = 2.0/(n*n - 3*n + 2); 43 44 typename graph_traits<Graph>::vertex_iterator v, v_end; 45 for (tie(v, v_end) = vertices(g); v != v_end; ++v) 46 { 47 put(vertex_betweenness, *v, factor * get(vertex_betweenness, *v)); 48 } 49 50 typename graph_traits<Graph>::edge_iterator e, e_end; 51 for (tie(e, e_end) = edges(g); e != e_end; ++e) 52 { 53 put(edge_betweenness, *e, factor * get(edge_betweenness, *e)); 54 } 55 } 56 38 57 struct get_betweenness 39 58 { … … 42 61 { 43 62 brandes_betweenness_centrality(g, vertex_index_map(index_map).edge_centrality_map(edge_betweenness).centrality_map(vertex_betweenness)); 63 normalize_betweenness(g, vertex_betweenness, edge_betweenness); 44 64 } 45 65 }; … … 61 81 weight_map = get_static_property_map<weight_map_t>(find_property_map(_dp, _weight, typeid(graph_traits<typename GraphInterface::multigraph_t>::edge_descriptor))); 62 82 brandes_betweenness_centrality(_g, vertex_index_map(_vertex_index).weight_map(weight_map).edge_centrality_map(_edge_betweenness).centrality_map(_vertex_betweenness)); 83 normalize_betweenness(_g, _vertex_betweenness, _edge_betweenness); 63 84 _found = true; 64 85 } … … 165 186 166 187 } 188 189 struct get_central_point_dominance 190 { 191 template <class Graph, class VertexBetweenness> 192 void operator()(Graph& g, VertexBetweenness vertex_betweenness, double& c) const 193 { 194 c = central_point_dominance(g, vertex_betweenness); 195 } 196 }; 197 198 199 double GraphInterface::GetCentralPointDominance(string vertex_betweenness) 200 { 201 try 202 { 203 typedef DynamicPropertyMapWrap<double, graph_traits<multigraph_t>::vertex_descriptor> betweenness_map_t; 204 betweenness_map_t betweenness(find_property_map(_properties, vertex_betweenness, typeid(graph_traits<multigraph_t>::vertex_descriptor))); 205 double c = 0.0; 206 207 bool reversed = this->GetReversed(); 208 bool directed = this->GetDirected(); 209 check_filter(*this, bind<void>(get_central_point_dominance(), _1, var(betweenness), var(c)), never_reversed(), always_directed()); 210 this->SetReversed(reversed); 211 this->SetDirected(directed); 212 return c; 213 } 214 catch (property_not_found) 215 { 216 throw GraphException("vertex property " + vertex_betweenness + " not found"); 217 } 218 } -
src/graph/graph_bind.cc
rba2aee r0075ec 241 241 .def("GetLineGraph", &GraphInterfaceWrap::GetLineGraph) 242 242 .def("GetBetweenness", &GraphInterfaceWrap::GetBetweenness) 243 .def("GetCentralPointDominance", &GraphInterfaceWrap::GetCentralPointDominance) 243 244 .def("GetCommunityStructure", &GraphInterfaceWrap::GetCommunityStructure) 244 245 .def("GetCommunityNetwork", &GraphInterfaceWrap::GetCommunityNetwork)
Note: See TracChangeset
for help on using the changeset viewer.


