10 lines
250 B
Python
10 lines
250 B
Python
|
|
def graph( segments ):
|
|
graph = {}
|
|
for start,end in segments:
|
|
graph[start] = graph.get( start, [] )
|
|
graph[start].append( end )
|
|
graph[end] = graph.get( end, [] )
|
|
graph[end].append( start )
|
|
return graph
|
|
|