00001 __copyright__ = """ 00002 Copyright 2008 Sean Ross-Ross 00003 """ 00004 __license__ = """ 00005 This file is part of SLIMpy . 00006 00007 SLIMpy is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 SLIMpy is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>. 00019 """ 00020 00021 def agvwidth( graph ): 00022 'some metric for how parallel a graph is' 00023 00024 prev = set( graph.getSourceNodes() ) 00025 tot = set( prev ) 00026 00027 widths = [] 00028 push = widths.append 00029 00030 while prev: 00031 push( len( prev ) ) 00032 next = set() 00033 for item in prev: 00034 nitem = graph.adj( item ) 00035 for i in nitem : 00036 if not i in tot: 00037 next.add( i ) 00038 tot.add( i ) 00039 prev = next 00040 00041 min_ = min( widths ) 00042 max_ = max( widths ) 00043 avg = sum( widths ) / float( len( widths ) ) 00044 return min_, max_, avg