(self)
return summary
Returns a string containing basic summary info of this Paths instance
Returns a string containing basic summary info of this Paths instance
Returns a string containing basic summary info of this Paths instance
def summary(self):
        """ 
        Returns a string containing basic summary info of this Paths instance
        """
        sum = 0
        spsum = 0
        lpsum = 0
        maxL = 0
        avgL = 0
        nodes = set()
        for k in self.paths:
            for p in self.paths[k]:
                sum += self.paths[k][p].sum()
                spsum += self.paths[k][p][0]
                lpsum += self.paths[k][p][1]
                avgL += self.paths[k][p][1] * k
                for v in p:
                    nodes.add(v)
            if len(self.paths[k])>0:
                maxL = max(maxL, k)
        if lpsum>0:
            avgL = avgL / lpsum

        summary = 'Number of paths (unique/sub paths/total):\t' +  str(lpsum) + ' (' + str(self.getUniquePaths()) + '/'+ str(spsum) + '/' + str(sum) + ')\n'
        summary += 'Nodes:\t\t\t\t' + str(len(nodes)) + '\n'
        summary += 'Edges:\t\t\t\t' + str(len(self.paths[1])) + '\n'
        summary += 'Max. path length:\t\t' + str(maxL) + '\n'
        summary += 'Avg path length:\t\t' + str(avgL) + '\n'
        for k in self.paths:
            sum = 0 
            spsum = 0
            lpsum = 0
            for p in self.paths[k]:
                sum += self.paths[k][p].sum()          
                spsum += self.paths[k][p][0]
                lpsum += self.paths[k][p][1]
            summary += 'Paths of length k = ' + str(k) + '\t\t' + str(lpsum) + ' (' + str(self.getUniquePaths(l=k, considerLongerPaths=False)) + '/' + str(spsum) + '/'+ str(sum) +  ')\n'
        return summary
def summary ( self ) : sum = 0 spsum = 0 lpsum = 0 maxL = 0 avgL = 0 nodes = set ( ) for k in self . paths : for p in self . paths [ k ] : sum += self . paths [ k ] [ p ] . sum ( ) spsum += self . paths [ k ] [ p ] [ 0 ] lpsum += self . paths [ k ] [ p ] [ 1 ] avgL += self . paths [ k ] [ p ] [ 1 ] * k for v in p : nodes . add ( v ) if len ( self . paths [ k ] ) > 0 : maxL = max ( maxL , k ) if lpsum > 0 : avgL = avgL / lpsum summary = 'Number of paths (unique/sub paths/total):\t' + str ( lpsum ) + ' (' + str ( self . getUniquePaths ( ) ) + '/' + str ( spsum ) + '/' + str ( sum ) + ')\n' summary += 'Nodes:\t\t\t\t' + str ( len ( nodes ) ) + '\n' summary += 'Edges:\t\t\t\t' + str ( len ( self . paths [ 1 ] ) ) + '\n' summary += 'Max. path length:\t\t' + str ( maxL ) + '\n' summary += 'Avg path length:\t\t' + str ( avgL ) + '\n' for k in self . paths : sum = 0 spsum = 0 lpsum = 0 for p in self . paths [ k ] : sum += self . paths [ k ] [ p ] . sum ( ) spsum += self . paths [ k ] [ p ] [ 0 ] lpsum += self . paths [ k ] [ p ] [ 1 ] summary += 'Paths of length k = ' + str ( k ) + '\t\t' + str ( lpsum ) + ' (' + str ( self . getUniquePaths ( l = k , considerLongerPaths = False ) ) + '/' + str ( spsum ) + '/' + str ( sum ) + ')\n' return summary