Example #1
0
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' )
Example #2
0
def main():
	'''

	main()

	Out: An image has been saved, makeTree.png,
		of a 100 vertex random tree.

	'''

	# Probability distribution xi, should have expected
	# value around 1.
	# Can be defined as a function...
	#xi = lambda x: scistats.geom.pmf(x+1,0.5)

	# ...or as a vector.
	w = [572,1,2,3,4,5,6,7,8,9,10,11,12]
	xi = 1.*np.array(w)/sum(w)

	print 'Make tree...'

	T = generateTree( xi, 100 )

	print 'Save...'

	graphUtil.saveGraph( T, 'makeTree' )

	print 'Ok.'
Example #3
0
def main():
    '''

	main()

	Out: An image has been saved, makeTree.png,
		of a 100 vertex random tree.

	'''

    # Probability distribution xi, should have expected
    # value around 1.
    # Can be defined as a function...
    #xi = lambda x: scistats.geom.pmf(x+1,0.5)

    # ...or as a vector.
    w = [572, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    xi = 1. * np.array(w) / sum(w)

    print 'Make tree...'

    T = generateTree(xi, 100)

    print 'Save...'

    graphUtil.saveGraph(T, 'makeTree')

    print 'Ok.'
Example #4
0
def main():
	'''

	main()
	
	Out: An image, treeToMobile.png, of a mobile 
		has been saved

	'''

	T = graphUtil.sampleTree()

	M = treeToMobile( T, 2 )
	
	graphUtil.saveGraph( T, 'tree' )

	graphUtil.saveGraph( M, 'treeToMobile' )
Example #5
0
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')
Example #6
0

# ---------------------------------------------
# ---------------------------------------------


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 )
Example #7
0

# ---------------------------------------------
# ---------------------------------------------


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, Point, 'shape' )
nx.set_node_attributes( G, Red, 'color' )