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 calcedgeprob function to create a dict containing edge probabilities between all pairs of leaf nodes. Then, complete the genrategraphfromprobs 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 genratehrggraphs function to genrate ngraphs HRG graphs using these edge probabilities and the genrategraphfromprobs function you just finished. This should work similarly to the functions in part but instead of calling a networkx generator, you'll call your own genrategraphfromprobs function inside the loop.
def calcedgeprobdendrogram: nxDiGraph Dictstr Dictstr float:
Inputs:
dendrogram: NetworkX graph object
Returns:
a dict of edge probabilities between all pairs of leaf nodes.
return edgeprobs
def genrategraphfromprobedgeprobs: Dictstr Dictstr float nxGraph:
Inputs:
edgeprobs: a dict of edge probabilities between all pairs of leaf nodes.
Returns:
H: NetworkX graph object
return H
def genratehrggraphsedgeprobs: Dictstr Dictstr float ngraphs: int ListnxGraph:
Inputs:
edgeprobs: a dict of edge probabilities between all pairs of leaf nodes.
ngraphs: 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
