#NEWLINE# def info( G , n = None ) : #NEWLINE# #INDENT# 'Print short summary of information for the graph G or the node n.\n\n    Parameters\n    ----------\n    G : Networkx graph\n       A graph\n    n : node (any hashable)\n       A node in the graph G\n    ' #NEWLINE# info = '' #NEWLINE# if ( n is None ) : #NEWLINE# #INDENT# info += ( 'Name: %s\n' % G . name ) #NEWLINE# type_name = [ type ( G ) . __name__ ] #NEWLINE# info += ( 'Type: %s\n' % ',' . join ( type_name ) ) #NEWLINE# info += ( 'Number of nodes: %d\n' % G . number_of_nodes ( ) ) #NEWLINE# info += ( 'Number of edges: %d\n' % G . number_of_edges ( ) ) #NEWLINE# nnodes = G . number_of_nodes ( ) #NEWLINE# if ( len ( G ) > 0 ) : #NEWLINE# #INDENT# if G . is_directed ( ) : #NEWLINE# #INDENT# info += ( 'Average in degree: %8.4f\n' % ( sum ( ( d for ( n , d ) in G . in_degree ( ) ) ) / float ( nnodes ) ) ) #NEWLINE# info += ( 'Average out degree: %8.4f' % ( sum ( ( d for ( n , d ) in G . out_degree ( ) ) ) / float ( nnodes ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# s = sum ( dict ( G . degree ( ) ) . values ( ) ) #NEWLINE# info += ( 'Average degree: %8.4f' % ( float ( s ) / float ( nnodes ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( n not in G ) : #NEWLINE# #INDENT# raise nx . NetworkXError ( ( 'node %s not in graph' % ( n , ) ) ) #NEWLINE# #UNINDENT# info += ( 'Node % s has the following properties:\n' % n ) #NEWLINE# info += ( 'Degree: %d\n' % G . degree ( s ) ) #NEWLINE# info += 'Neighbors: ' #NEWLINE# info += ' ' . join ( ( str ( nbr ) for nbr in G . neighbors ( n ) ) ) #NEWLINE# #UNINDENT# return info