1 | initial version |

kcrisman's answer works for converting the networkx graph to a sage graph. As he points out Sage has its own implementations of mst algorithms (see here for documentation, you can use the algorithm from networkx too :-). See an example below.

```
sage: Z=Graph(G.min_spanning_tree(algorithm='Kruskal'))
```

It seems that the format you are reading from is the edge list format from here. If this is the case, then you can easily save graph `Z`

with the following commands.

```
sage: f=open('Z.csv','w')
sage: f.write('\n') # We write the blank line at the top
sage: Zwriter = csv.writer(f,delimiter=';')
sage: Zwriter.writerows(Z.edges(labels=None))
sage: f.close()
```

2 | No.2 Revision |

kcrisman's answer works for converting the networkx graph to a sage graph. As he points out Sage has its own implementations of mst algorithms (see here for documentation, you can use the algorithm from networkx too :-). See an example below.

```
sage: Z=Graph(G.min_spanning_tree(algorithm='Kruskal'))
```

It seems that the format you are reading from is the edge list format from here. If this is the case, then you can easily save graph `Z`

with the following commands.

```
sage: f=open('Z.csv','w')
sage: f.write('\n') # We write the blank line at the top
sage: Zwriter = csv.writer(f,delimiter=';')
sage: Zwriter.writerows(Z.edges(labels=None))
sage: f.close()
```

Assuming you are reading from the format mentioned above, it might be possible to read the graph in one line as shown below.

```
sage: f=open('Z.csv','r')
sage: Hreader = csv.reader(f,delimiter=';')
sage: H = Graph([(int(u),int(v)) for u,v in Hreader])
sage: f.close()
```

3 | No.3 Revision |

kcrisman's answer works for converting the networkx graph to a sage graph. As he points out Sage has its own implementations of mst algorithms (see here for documentation, you can use the algorithm from networkx too :-). See an example below.

```
sage: Z=Graph(G.min_spanning_tree(algorithm='Kruskal'))
```

It seems that the format you are reading from is the edge list format from here. If this is the case, then you can easily save graph `Z`

with the following commands.

```
sage: f=open('Z.csv','w')
sage: f.write('\n') # We write the blank line at the top
sage: Zwriter = csv.writer(f,delimiter=';')
sage: Zwriter.writerows(Z.edges(labels=None))
sage: f.close()
```

Assuming you are reading from the format mentioned above, it might be possible to read the graph in one line as shown below.

```
sage: f=open('Z.csv','r')
sage:
```~~Hreader ~~Zreader = csv.reader(f,delimiter=';')
sage: ~~H ~~Z = Graph([(int(u),int(v)) for u,v in ~~Hreader])
~~Zreader])
sage: f.close()

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.