Commit 98ee958f authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Convert histograms counts to float64 by default

parent ccebfe00
......@@ -41,33 +41,33 @@ from numpy import *
__all__ = ["vertex_hist", "edge_hist", "label_components",
"label_parallel_edges", "label_self_loops"]
def vertex_hist(g, deg, bins=[1]):
def vertex_hist(g, deg, bins=[1], float_count=True):
ret = libgraph_tool_stats.\
get_vertex_histogram(g._Graph__graph, _degree(g, deg), bins)
return [array(ret[0]), ret[1]]
return [array(ret[0], dtype="float64") if float_count else ret[0], ret[1]]
def edge_hist(g, eprop, bins=[1]):
def edge_hist(g, eprop, bins=[1], float_count=True):
ret = libgraph_tool_stats.\
get_edge_histogram(g._Graph__graph, _prop("e", g, eprop), bins)
return [array(ret[0]), ret[1]]
return [array(ret[0], dtype="float64") if float_count else ret[0], ret[1]]
def label_components(g, vprop=None):
if vprop == None:
vprop = g.new_vertex_property("int32_t")
libgraph_tool_stats.\
label_components(g._Graph__graph, _prop("v", g, vprop))
return _prop("v", g, vprop)
return vprop
def label_parallel_edges(g, eprop):
if eprop == None:
eprop = g.new_edge_property("int32_t")
libgraph_tool_stats.\
label_parallel_edges(g._Graph__graph, _prop("e", g, eprop))
return _prop("e", g, eprop)
return eprop
def label_self_loops(g, eprop):
if eprop == None:
eprop = g.new_edge_property("int32_t")
libgraph_tool_stats.\
label_self_loops(g._Graph__graph, _prop("e", g, eprop))
return _prop("e", g, eprop)
return eprop
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment