Question: Finish the calc _ edge _ prob function to create a dict containing edge probabilities between all pairs of leaf nodes. Then, complete the genrate

Finish the calc_edge_prob function to create a dict containing edge probabilities between all pairs of leaf nodes. Then, complete the genrate_graph_from_probs function to genrate a networkx graph based on these calcd probabilities. Specifically, for any two nodes, i and j, with a prob p of having an edge, genrate an edge randomly with a prob of p for each pair of nodes.
Finally, complete the genrate_hrg_graphs function to genrate n_graphs=100 HRG graphs using these edge probabilities and the genrate_graph_from_probs function you just finished. This should work similarly to the functions in part 2.1, but instead of calling a networkx generator, you'll call your own genrate_graph_from_probs function inside the loop.
def calc_edge_prob(dendrogram: nx.DiGraph)-> Dict[str, Dict[str, float]]:
"""
Inputs:
dendrogram: NetworkX graph object
Returns:
a dict of edge probabilities between all pairs of leaf nodes.
"""
return edge_probs
def genrate_graph_from_prob(edge_probs: Dict[str, Dict[str, float]])-> nx.Graph:
"""
Inputs:
edge_probs: a dict of edge probabilities between all pairs of leaf nodes.
Returns:
H: NetworkX graph object
"""
return H
def genrate_hrg_graphs(edge_probs: Dict[str, Dict[str, float]], n_graphs: int=100)-> List[nx.Graph]:
"""
Inputs:
edge_probs: a dict of edge probabilities between all pairs of leaf nodes.
n_graphs: int
Returns:
a list of NetworkX graph object
"""
return graphs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!