Skip to content

davidmarcus/roads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

roads

An analysis of road network optimization

Also, see the wiki for non-code analysis, specifically the page on Analyzing regular tesselations.

Installation

sudo apt-get -y install ipython
sudo pip install -r requirements.txt

Execution

Code is currently contained entirely within roads.py. It's easiest to interact with the code using an ipython shell.

Examples

###Create a graph for a 4x4 grid

from roads import *

G = RoadGraph.grid_graph(4, 4)

###Visualize the graph

G.show()

###Calculate key metrics for the graph

print 'graph_length=%s' % G.length
print 'mean_path_length=%s' % G.mean_path_length

###Drop two edges from the graph

edge = G.get_removal_target()
G.remove_edge(*edge)
edge = G.get_removal_target()
G.remove_edge(*edge)
show(G)

###Add an edge to the graph

edge = G.get_addition_target()
G.add_edge(*edge)
show(G)

###Add or remove edges, depending on whether there is capacity for a new edge without exceeding the target graph_length

for i in xrange(10):  # run 10 iterations of adding or removing edges
  G.iterate()
show(G)

About

An analysis of road network optimization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages