This question is more related to resources that I might not have identified yet, although I've been searching the web for a while.
In the project I'm working at the moment I need to run a shortest-path algorithm on a graph representing office rooms, corridors, stairs, lifts and routes between buildings.
For the presentation layer I thought of using Python scripting with MapServer, but now I'm giving more thought into how to build the graph from the (shapefiles conveted into a) postGIS db generated from OpenEV so that it's easy to add and remove edges or weights or information about the points afterwards.
For Python there's a module called networkX that deals with graphs, and although this issue has been brought up in stackexchange here, the graph I'm trying to build is not a digraph but an undirectional one.
Update: 5 days ago Ben Reilly's utilitynetwork has been added to the networkX project. Utilitynetwork builds a directed graph from shapefile features.
The questions remains open for a similar approach of reading features from the postGIS database.
Answer
NetworkX has a method to convert directed graphs into undirected ones.
Additionally, the code to read a shapefile (or directory of shapefiles) doesn't really need to output a directed graph, that's just what I needed at the time. I haven't tried, but replacing the single line:
net = nx.DiGraph()
...might just do the trick.
NetworkX looks like it will support reading shapefiles out of the box (with OGR) in 1.4 (feature).
No comments:
Post a Comment