def main(): ''' main() Out: Three images have been saved, 1) A bipartite Halin graph, bdg_halin0.png 2) Its corresponding mobile, bdg_mobile.png 3) The planar map corresponding to the mobile, bdg_halin1.png. Note: not necessarily the same graph as 1), since the BDG bijection depends on the embedding of the graph. ''' # Make a mobile T = graphUtil.sampleTree() M = treeToMobile.treeToMobile( T, labels = 2 ) # Map the mobile to a graph. G = mobileToGraph( M, eps = graphUtil.coin() ) graphUtil.saveGraph( M, 'bdg_M' ) graphUtil.saveGraph( G, 'bdg_G' )
def main(): ''' main() Out: Three images have been saved, 1) A bipartite Halin graph, bdg_halin0.png 2) Its corresponding mobile, bdg_mobile.png 3) The planar map corresponding to the mobile, bdg_halin1.png. Note: not necessarily the same graph as 1), since the BDG bijection depends on the embedding of the graph. ''' # Make a mobile T = graphUtil.sampleTree() M = treeToMobile.treeToMobile(T, labels=2) # Map the mobile to a graph. G = mobileToGraph(M, eps=graphUtil.coin()) graphUtil.saveGraph(M, 'bdg_M') graphUtil.saveGraph(G, 'bdg_G')
xi = 1. * np.array(w) / sum(w) mob_lab = 1 # --------------------------------------------- # --------------------------------------------- #print 'Make tree...' T = makeTree.generateTree(xi, n) #print 'Map to mobile...' M = treeToMobile.treeToMobile(T, mob_lab) #print 'Map to planar...' G = bdg.mobileToGraph(M, graphUtil.coin()) # --------------------------------------------- # --------------------------------------------- #graphUtil.saveGraph( G, 'maxim', draw = True, write = False, prog = 'fdp' ) Nodes = G.nodes() d = nx.diameter(G) count = 0 # Skodum alla hnuta i G og vitum hvort their myndi upphof. for u in Nodes:
print 'Make tree...' T = makeTree.generateTree( xi, n ) print 'Map to mobile...' M = treeToMobile.treeToMobile( T, labels = mob_lab ) print 'Save mobile...' graphUtil.saveGraph( M, file_name + 'mobile' ) print 'Map to planar...' G = bdg.mobileToGraph( M, graphUtil.coin() ) # Appearance Point = dict(zip( G.nodes(), [ 'point' ] * len(T) )) Red = dict(zip( G.nodes(), [ 'red' ] * len(T) )) nx.set_node_attributes( G, 'shape', Point ) nx.set_node_attributes( G, 'color', Red ) G.node[ 'rho' ][ 'color' ] = 'green'