;i`dZddZdZd dZdS) z altgraph.GraphStat - Functions providing various graph statistics ================================================================= r outcg}|dkr|j}n|j}|D] }|||!|sgSt|||}|S)a: Computes the degree distribution for a graph. Returns a list of tuples where the first element of the tuple is the center of the bin representing a range of degrees and the second element of the tuple are the number of nodes with the degree falling in the range. Example:: .... inc)valueslimitsbin_num) inc_degree out_degreeappend_binning)graphr r modedegget_degnoderesultss FC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\altgraph/GraphStat.py degree_distrsv C u}}"""" 774==!!!!  c&'BBBG Ng=c|dkr/t|tz t|tz}}n|\}}||z t|z }dg|z}|D]N} ||z dkr2t ||z t|z }||xxdz cc<?#t $rYKwxYwg} |dz |z} t |D]$\} } | || zz} | | | f%| S)a Bins data that falls between certain limits, if the limits are (0, 0) the minimum and maximum values are used. Returns a list of tuples where the first element of the tuple is the center of the bin and the second element of the tuple are the counts. rr)min_EPSmaxfloatint IndexError enumerater )rr r min_valmax_valbin_sizebinsvalueindexresultcenteriyxs rrr(s.v;;-s6{{T/A!'!U7^^3H 3'?D A%%UW_h?@@U q     D Flg %F$1 X\ ! q!f Ms;B B$#B$N)rrr)rr)__doc__rrrrrr/sH <!!!!!!r