Untitled
import matplotlib.pyplot as plt import networkx as nx # Create the decision tree graph G = nx.DiGraph() # Add nodes G.add_node("Identify Ethical Dilemma", pos=(0, 10)) G.add_node("Disclose the Issues", pos=(-5, 7)) G.add_node("Withhold the Information", pos=(5, 7)) G.add_node("Evaluate Professional Ethics", pos=(-8, 4)) G.add_node("Consider Long-Term Reputation", pos=(-6, 2)) G.add_node("Assess Impact on Buyers", pos=(-4, 0)) G.add_node("Communicate the Findings", pos=(-6, -2)) G.add_node("Evaluate Personal Values", pos=(8, 4)) G.add_node("Consider Financial Gain", pos=(6, 2)) G.add_node("Assess Legal and Ethical Risks", pos=(4, 0)) G.add_node("Reflect on Future Client Relationships", pos=(6, -2)) G.add_node("Final Decision: Disclose the Issues", pos=(0, -4)) # Add edges G.add_edges_from([ ("Identify Ethical Dilemma", "Disclose the Issues"), ("Identify Ethical Dilemma", "Withhold the Information"), ("Disclose the Issues", "Evaluate Professional Ethics"), ("Evaluate Professional Ethics", "Consider Long-Term Reputation"), ("Consider Long-Term Reputation", "Assess Impact on Buyers"), ("Assess Impact on Buyers", "Communicate the Findings"), ("Withhold the Information", "Evaluate Personal Values"), ("Evaluate Personal Values", "Consider Financial Gain"), ("Consider Financial Gain", "Assess Legal and Ethical Risks"), ("Assess Legal and Ethical Risks", "Reflect on Future Client Relationships"), ("Communicate the Findings", "Final Decision: Disclose the Issues"), ("Reflect on Future Client Relationships", "Final Decision: Disclose the Issues") ]) # Get positions pos = nx.get_node_attributes(G, 'pos') # Draw the graph plt.figure(figsize=(12, 8)) nx.draw(G, pos, with_labels=True, node_color='skyblue', node_size=4000, font_size=10, font_weight='bold', edge_color='gray', linewidths=2, arrowsize=20) plt.title("Decision Tree: Ethical Dilemma in Real Estate", size=15) plt.show()
Leave a Comment