<｜begin▁of▁sentence｜>### Instruction:
Given an LGL file named 'network.lgl', which may contain named and optionally weighted edges for a directed graph, how can you create and summarize a graph in igraph from this file, including checking for and printing edge weights if they exist?
### Response:
import igraph as ig

# Read an LGL file and create a graph
file_name = 'network.lgl'
graph = ig.Graph.Read_Lgl(file_name, names=True, weights='if_present', directed=True)

# Print the summary of the graph
print(graph.summary())

# If the graph has a 'weight' edge attribute, print the weights
if 'weight' in graph.es.attributes():
    print(graph.es['weight'])
<|EOT|>
