<｜begin▁of▁sentence｜>### Instruction:
Suppose you have a directed graph with the edge set and respective weights: [(1, 2, 0.5), (1, 3, 1.5), (2, 3, 2.0), (3, 1, 0.7)]. How can you transform this into a right-stochastic graph, where the out-edges of each node sum up to 1, while taking into account the original edge weights if present?
### Response:
import networkx as nx

# Create a directed graph
G = nx.DiGraph()
G.add_weighted_edges_from([(1, 2, 0.5), (1, 3, 1.5), (2, 3, 2.0), (3, 1, 0.7)])

# Convert to right-stochastic graph
stochastic_G = nx.stochastic_graph(G, copy=True)

# Print the edge weights
for edge in stochastic_G.edges(data=True):
    print(edge)
<|EOT|>
