Ask Your Question

Melanie's profile - activity

2023-07-16 19:47:14 +0200 received badge  Nice Question (source)
2018-01-26 21:35:44 +0200 received badge  Famous Question (source)
2018-01-26 21:35:44 +0200 received badge  Popular Question (source)
2018-01-26 21:35:44 +0200 received badge  Notable Question (source)
2014-10-28 14:44:36 +0200 asked a question Networkx graph to Sage graph? + Export graph to csv?

Hi everybody,

I want to work with networkx, in particular with algorithms in networkx. I know how to import a graph with data from a csv-file and how to convert a Sage graph into a networkx graph. Therefor my code:

import csv
f=open(DATA+'example','r')
data=csv.reader(f,delimiter=';')
data=[row for row in data]
f.close()
data=[(column[0:]) for column in data[1:]]
data
Liste=[]
for row in data:
     Tupel=()
     for item in row:
          titem=(int(item),)
          Tupel=Tupel+titem
     Liste.append(Tupel)
print Liste
G=Graph(Liste)
import networkx as nx
H=G.networkx_graph()
h=nx.minimum_spanning_tree(H)

What do I have to do to convert my so called h-graph into a Sage graph? And how to get the results back into a csv-file?

Thanks in advance!

2014-10-13 16:46:55 +0200 received badge  Student (source)
2014-10-08 11:40:15 +0200 commented question Sage: How to import a graph from a shapefile into Sage?

Yes, I run it in the Oracle VM. Thanks for your answers!

2014-09-26 13:52:24 +0200 asked a question Sage: How to import a graph from a shapefile into Sage?

I would like to import a graph and afterwards use functions from the networkx library in the Sage Notebook. Python is totally new for me and I have not that much experience with programming. How to transfer a shapefile into Sage? I tried

import networkx as nx 

g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)

That gives

ImportError: read_shp requires OGR: http://www.gdal.org/

Unfortunately, this link doesn’t help me. Thank you in advance