Skip to content

Commit

Permalink
Wornking on the example
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielspadon committed Feb 4, 2019
1 parent b2e5b55 commit 8fbc1ee
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 125,873 deletions.
115,450 changes: 0 additions & 115,450 deletions data/file.graphml

This file was deleted.

7,368 changes: 0 additions & 7,368 deletions data/supplementary.txt

This file was deleted.

1,058 changes: 0 additions & 1,058 deletions notebook/.ipynb_checkpoints/ICN-Example-checkpoint.ipynb

This file was deleted.

1,931 changes: 0 additions & 1,931 deletions notebook/ICN-Example.ipynb

This file was deleted.

355 changes: 355 additions & 0 deletions notebook/SC-Example.ipynb

Large diffs are not rendered by default.

64 changes: 6 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,9 @@
"""
StreetContinuity (SC)
========
StreetContinuity (SC) is a python library that implements both Intersection Continuity Negotiation (ICN) and
Hierarchical Intersection Continuity Negotiation (HICN). ICN was first proposed by Porta et al. (2006) and
further enhanced by Masucci et al. (2014), who advanced with the HICN approach.
For details about each implementation, please refer to:
[1] Sergio Porta, Paolo Crucitti, Vito Latora, "The network analysis of urban streets: A dual approach", Physica A:
Statistical Mechanics and its Applications, Volume 369, Issue 2, 2006, Pages 853-866, ISSN 0378-4371.
[2] Masucci, A. P., Stanilov, K., Batty, M. (2014). "Exploring the evolution of London's street
network in the information space: A dual approach." Physical Review E, 89(1), 012805.
I want to thank Elisabeth H. Krueger and Xianyuan Zhan, who provide me with their version of the HICN.
Their code gave some insights and helped in the process of validation of the results.
For details about their implementation, please refer to:
[3] Krueger, E., Klinkhamer, C., Urich, C., Zhan, X., & Rao, P. S. C. (2017). "Generic patterns in the evolution
of urban water networks: Evidence from a large Asian city". Physical Review E, 95(3), 032312.
Portfolio::
https://spadon.com.br/
Source::
https://github.com/gabrielspadon/StreetContinuity
Bug reports::
https://github.com/gabrielspadon/StreetContinuity/issues
Simple example
--------------
>>> from street_continuity.all import *
>>> import osmnx as ox
>>> oxg = ox.graph_from_point((-22.012282, -47.890821), distance=5000)
>>> p_graph = from_osmnx(oxg=oxg, use_label=True)
>>> d_graph = dual_mapper(primal_graph=p_graph, min_angle=120)
>>> write_graphml(graph=d_graph, filename='file.graphml', directory='../data')
>>> write_supplementary(graph=d_graph, filename='supplementary.txt', directory='../data')
Bugs
----
Please report any bugs that you find at https://github.com/gabrielspadon/StreetContinuity/issues.
Or, even better, fork the repository on GitHub and create a pull request.
License
-------
Released under the GNU General Public License v3.0 (GLP-3.0).
Copyright 2019, Gabriel Spadon, all rights reserved.
www.spadon.com.br & gabriel@spadon.com.br
"""
#
# Copyright 2019, Gabriel Spadon, all rights reserved.
# This code is under GNU General Public License v3.0.
# www.spadon.com.br & gabriel@spadon.com.br
#
# Verified on February 4th, 2019.

from setuptools import setup

Expand Down
63 changes: 57 additions & 6 deletions street_continuity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,61 @@
#
# Copyright 2019, Gabriel Spadon, all rights reserved.
# This code is under GNU General Public License v3.0.
# www.spadon.com.br & gabriel@spadon.com.br
#
# Verified on February 4th, 2019.
"""
StreetContinuity (SC)
========
StreetContinuity (SC) is a python library that implements both Intersection Continuity Negotiation (ICN) and
Hierarchical Intersection Continuity Negotiation (HICN). ICN was first proposed by Porta et al. (2006) and
further enhanced by Masucci et al. (2014), who advanced with the HICN approach.
For details about each implementation, please refer to:
[1] Sergio Porta, Paolo Crucitti, Vito Latora, "The network analysis of urban streets: A dual approach", Physica A:
Statistical Mechanics and its Applications, Volume 369, Issue 2, 2006, Pages 853-866, ISSN 0378-4371.
[2] Masucci, A. P., Stanilov, K., Batty, M. (2014). "Exploring the evolution of London's street
network in the information space: A dual approach." Physical Review E, 89(1), 012805.
I want to thank Elisabeth H. Krueger and Xianyuan Zhan, who provide me with their version of the HICN.
Their code gave some insights and helped in the process of validation of the results.
For details about their implementation, please refer to:
[3] Krueger, E., Klinkhamer, C., Urich, C., Zhan, X., & Rao, P. S. C. (2017). "Generic patterns in the evolution
of urban water networks: Evidence from a large Asian city". Physical Review E, 95(3), 032312.
Portfolio::
https://spadon.com.br/
Source::
https://github.com/gabrielspadon/StreetContinuity
Bug reports::
https://github.com/gabrielspadon/StreetContinuity/issues
Simple example
--------------
>>> from street_continuity.all import *
>>> import osmnx as ox
>>> oxg = ox.graph_from_point((-22.012282, -47.890821), distance=5000)
>>> p_graph = from_osmnx(oxg=oxg, use_label=True)
>>> d_graph = dual_mapper(primal_graph=p_graph, min_angle=120)
>>> write_graphml(graph=d_graph, filename='file.graphml', directory='../data')
>>> write_supplementary(graph=d_graph, filename='supplementary.txt', directory='../data')
Bugs
----
Please report any bugs that you find at https://github.com/gabrielspadon/StreetContinuity/issues.
Or, even better, fork the repository on GitHub and create a pull request.
License
-------
Released under the GNU General Public License v3.0 (GLP-3.0).
Copyright 2019, Gabriel Spadon, all rights reserved.
www.spadon.com.br & gabriel@spadon.com.br
"""

import sys

Expand Down
5 changes: 3 additions & 2 deletions street_continuity/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def write_graphml(graph: DualGraph, filename: str = 'file.graphml', directory: s
:param graph: a DualGraph mapped from a PrimalGraph
:param filename: name of the output file
:param directory: full path to save the file
:return: None
:return: NetworkX Graph
"""

nxg = nx.Graph()
Expand All @@ -164,6 +164,7 @@ def write_graphml(graph: DualGraph, filename: str = 'file.graphml', directory: s
# GraphML does not support lists and dictionaries as objects, so we must add attributes one by one
nxg.node[nid]['names'] = str(data.names)
nxg.node[nid]['nodes'] = str(data.nodes)
nxg.node[nid]['edges'] = str(data.edges)
nxg.node[nid]['source'] = data.source
nxg.node[nid]['target'] = data.target
nxg.node[nid]['length'] = data.length
Expand All @@ -183,4 +184,4 @@ def write_graphml(graph: DualGraph, filename: str = 'file.graphml', directory: s
# writing the resulting graph to the informed file path
nx.write_graphml(G=nxg, path=filepath, encoding='utf-8', prettyprint=True, infer_numeric_types=False)

return
return nxg
1 change: 1 addition & 0 deletions street_continuity/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, did: int, pge: PrimalGraph.Edge):
self.names = [pge.name] # [list] list with names of all primal edges;
self.nodes = [pge.source, # [list] list of all primal nodes within the dual node; and,
pge.target]
self.edges = [(pge.source, pge.target)] # TODO ...
self.did = did # [integer] dual node index.

# --- nested class --- #
Expand Down
2 changes: 2 additions & 0 deletions street_continuity/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ def extend_neighborhood(primal_graph: PrimalGraph, neighborhood: list, dual_node
primal_graph.edge_dictionary[eid].mapped = True

if is_upstream:
dual_node.edges.insert(0, (candidate, dual_node.source)) # TODO ...
dual_node.source = candidate # to upstream neighborhood, we update the source of the dual node
else:
dual_node.edges.append((dual_node.target, candidate)) # TODO ...
dual_node.target = candidate # otherwise, we update the dual node target

# the length of the street grows by summing the old length with the one from the merged primal edge
Expand Down

0 comments on commit 8fbc1ee

Please sign in to comment.