def create_2node_graph(): """ Simple 2 node undirected graph """ g = UPGraph() g.add_node(1, single_potential_1, [0, 1]) g.add_node(2, single_potential_2, [0, 1]) g.connect(1, 2, pairwise_potential) return g
def create_problem3b_graph(): """" Creates the graph structure, and associates potentials with graph structure """ g = UPGraph() #create 6 nodes in graph for k in range(6): id = k+1 if id in (1, 3, 5): pfunc = single_potential_1 else: pfunc = single_potential_2 g.add_node(id, pfunc, [0, 1]) #add edges between relevant nodes for figure 1 g.connect(1, 2, pairwise_potential) g.connect(1, 3, pairwise_potential) g.connect(2, 4, pairwise_potential) g.connect(2, 5, pairwise_potential) g.connect(3, 6, pairwise_potential) return g