get list in python
<pre><code>#ideal nodes list should be
['A','B','C','D','E','F','G','H','I','J','K','L','M','N']
</code></pre>

<p>So I tried to write a definition to read the nodes and edges.Here is my code,but it seems does not work.</p>

<pre><code>""" read nodes"""
def rd_nodes(a):
    nline =[line.split(":")[1].replace(';',',').split(',') for line in a]
    for i in nline:
        return i
</code></pre>

<p>As @skovorodkin has the correct answer, but if you want pure Python version (Though I wonder why) you could use this code</p>

<pre><code>s = """
1:A,B,C,D;E,F
2:G,H;J,K
&amp;:L,M,N
"""
def combinations(nodes):
    if len(nodes) &lt; 2:
        return (tuple(nodes))
    else:
        i = 1
        ret_tuple = []
        for n in nodes:
            rest = nodes[i:]
            for r in rest:
                ret_tuple.append(tuple([n,r]))
            i += 1

        return tuple(ret_tuple)

nodes = set()
edges = set()

for line in s.split():
    clusters = line.split(':')[1].split(';')
    for cluster in clusters:
        _nodes = cluster.split(',')
        nodes.update(_nodes)
        edges.update(combinations(_nodes))

print nodes
print edges
</code></pre>

python list edges