Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
1.5 kB
3
Indexable
Never
# Create a directed graph for Monica's Sailboat Company decision problem
G2 = nx.DiGraph()

# Adding nodes for Monica's Decision
G2.add_node("Start", label="Start Decision", pos=(0, 0))

# Options for Monica's Decision
G2.add_node("Large Facility", label="Large Facility", pos=(1, 1))
G2.add_node("Small Facility", label="Small Facility", pos=(1, -1))
G2.add_node("No Business", label="No Business", pos=(1, -2))

# Outcomes for Large Facility
G2.add_node("LF_Fav", label="Favorable Market (Large)", pos=(2, 1.5))
G2.add_node("LF_Unfav", label="Unfavorable Market (Large)", pos=(2, 0.5))

# Outcomes for Small Facility
G2.add_node("SF_Fav", label="Favorable Market (Small)", pos=(2, -0.5))
G2.add_node("SF_Unfav", label="Unfavorable Market (Small)", pos=(2, -1.5))

# Edges representing decision paths for Monica's problem
G2.add_edges_from([
    ("Start", "Large Facility"), ("Start", "Small Facility"), ("Start", "No Business"),
    ("Large Facility", "LF_Fav"), ("Large Facility", "LF_Unfav"),
    ("Small Facility", "SF_Fav"), ("Small Facility", "SF_Unfav")
])

# Labels for each node
labels2 = nx.get_node_attributes(G2, 'label')
positions2 = nx.get_node_attributes(G2, 'pos')

# Draw the graph for Monica's decision tree
plt.figure(figsize=(8, 6))
nx.draw(G2, positions2, labels=labels2, with_labels=True, node_size=2000, node_color='lightgreen', font_size=8, font_color='black', font_weight='bold', edge_color='gray')
plt.title("Decision Tree for Monica's Sailboat Company")
plt.show()
Leave a Comment