<｜begin▁of▁sentence｜>### Instruction:
Given an .ncol file that contains named and optionally weighted edges for a graph, how can you read this file into an igraph object, including the handling of names and weights, and whether to interpret the edges as directed or undirected?
### Response:
import igraph as ig
# Load graph from .ncol file
ncol_file = 'path/to/your/file.ncol'
g = ig.Graph.Read_Ncol(ncol_file, names=True, weights='if_present', directed=False)
# If you used names=True, access the name vertex attribute
if 'name' in g.vs.attributes():
    print('Vertex names:', g.vs['name'])
# If weights were added, access the weight edge attribute
if 'weight' in g.es.attributes():
    print('Edge weights:', g.es['weight'])
<|EOT|>
