let degree graph =
let nv = G.nb_vertex graph in
let outmax = ref 0 in
let inmax = ref 0 in
let outh = Hashtbl.create 1031 in
let inh = Hashtbl.create 1031 in
let add h d =
if d = 0 then () else
try Hashtbl.replace h d ((Hashtbl.find h d) + 1)
with Not_found -> Hashtbl.add h d 1
in
let total =
G.fold_vertex (fun v sum ->
let outdeg = G.out_degree graph v in
let indeg = G.in_degree graph v in
add outh outdeg;
add inh indeg;
_indatadegree := MSin.add (v,ref graph) indeg !_indatadegree;
_outdatadegree := MSout.add (v,ref graph) outdeg !_outdatadegree;
sum + indeg
) graph 0
in
( (float_of_int total) /. (float_of_int nv) , !outmax, !inmax, outh, inh)