def test_networkx_graphs():
	G = nx.path_graph(10)
	mc_srw = mkm.nx_graph_srw(G)
	mc_lswr = mkm.nx_graph_lazy_srw(G)

	G = nx.hypercube_graph(10)
	print nx.number_of_nodes(G)
	mkm.nx_graph_lazy_srw(G)

	G = nx.complete_graph(50)
	print mkm.nx_graph_nbrw(G).get_n()
Esempio n. 2
0
def test_networkx_graphs():
    G = nx.path_graph(10)
    mc_srw = mkm.nx_graph_srw(G)
    mc_lswr = mkm.nx_graph_lazy_srw(G)

    G = nx.hypercube_graph(10)
    print nx.number_of_nodes(G)
    mkm.nx_graph_lazy_srw(G)

    G = nx.complete_graph(50)
    print mkm.nx_graph_nbrw(G).get_n()
def nx_graph_analyze_lazy_srw(G):  # pragma: no cover
    import networkx as nx
    import matplotlib.pyplot as plt

    mc = mkm.nx_graph_lazy_srw(G)
    mc.add_distributions(mkm.random_delta_distributions(mc.get_n(), 5))

    mc.compute_tv_mixing()

    plt.figure()
    for i in range(mc.num_distributions()):
        (x, tv) = mc.distribution_tv_mixing(i)
        plt.plot(x, tv)

    plt.xlabel("t")
    plt.ylabel("Distance to stationary distribution in total variation")
    plt.show()
def nx_graph_analyze_lazy_srw(G): # pragma: no cover
	import networkx as nx
	import matplotlib.pyplot as plt

	mc = mkm.nx_graph_lazy_srw(G)
	mc.add_distributions(mkm.random_delta_distributions(mc.get_n(),5))
	
	mc.compute_tv_mixing()

	plt.figure()
	for i in range(mc.num_distributions()):
		(x,tv) = mc.distribution_tv_mixing(i)
		plt.plot(x, tv)

	plt.xlabel("t")
	plt.ylabel("Distance to stationary distribution in total variation")
	plt.show()	
Esempio n. 5
0
import markovmixing as mkm
import networkx as nx
import numpy as np

####################### 50-CYCLE EXAMPLE #########################
# create a graph
G = nx.cycle_graph(50)
    
# create a MarkovChain that is lazy simple random walk on the graph
mc = mkm.nx_graph_lazy_srw(G)

# plot the total variation mixing
mc.add_random_delta_distributions(1)
mc.plot_tv_mixing(y_tol=0.01, threshold=0.01)  


####################### BIASED LINE EXAMPLE #########################
# create the transition matrix
P = mkm.line_lazy_transition_matrix(1000, p=0.51)

# create the MarkovChain with the given transition matrix
mc = mkm.MarkovChain(P)
    
# add some initial distributions
for i in [0,500,999]:
	mc.add_distributions(mkm.delta_distribution(1000,x=i))
        
# plot the total variation mixing
mc.plot_tv_mixing(y_tol=0.01, threshold=1e-5)